dbutil

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustMakeMigrationsWithSeedSource

func MustMakeMigrationsWithSeedSource(migrationsFS fs.FS, seedFS fs.FS) string

MustMakeMigrationsWithSeedSource builds a temporary directory with existing migrations and a seed SQL files, and returns the directory location in a format of a valid migrations source path for `migrate` tool.

This is necessary since `migrate` requires all migration files to be in the same location.

func MustRunDownMigrations

func MustRunDownMigrations(migrationsSource, dsn string)

func MustRunUpMigrations

func MustRunUpMigrations(migrationsSource, dsn string)

func RunDownMigrations

func RunDownMigrations(migrationsSource, dsn string) error

RunDownMigrations will run all down migrations. * Assume database is ready for connections * Most common migration source: "file://migrations" (import "github.com/golang-migrate/migrate/v4/source/file") * dsn should start with database name: "mysql://root@tcp(localhost:3306)/db" (import "github.com/golang-migrate/migrate/v4/database/mysql")

func RunUpMigrations

func RunUpMigrations(migrationsSource, dsn string) error

RunUpMigrations will run all up migrations. * Assume database is ready for connections * Most common migration source: "file://migrations" (import "github.com/golang-migrate/migrate/v4/source/file") * dsn should start with database name: "mysql://root@tcp(localhost:3306)/db" (import "github.com/golang-migrate/migrate/v4/database/mysql")

func SplitDSN

func SplitDSN(dsn string) (string, string)

SplitDSN will extract DSN (without db name) and database name.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL