Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Down ¶
func Down(c *SQLConnection) (record string, err error)
Down reverts a single database migration. It returns the reverted migration name.
func Sync ¶
func Sync(c *SQLConnection) (done []string, err error)
Sync migrates the database to latest schema.
func Up ¶
func Up(c *SQLConnection) (record string, err error)
Up executes a single database migration. It returns the last migration name.
Types ¶
type LocalMigrationSource ¶
type LocalMigrationSource struct {
Dir string
}
LocalMigrationSource migrates from a local files.
func (LocalMigrationSource) FindMigrations ¶
func (l LocalMigrationSource) FindMigrations() (m []*migrate.Migration, err error)
FindMigrations implements migrate.MigrationSource{} interface.
type SQLConfig ¶
type SQLConfig struct { Dialect string Address string // Format like "host:port" Database string User string Password string }
SQLConfig is config for SQL connection.
type SQLConnection ¶
type SQLConnection struct {
// contains filtered or unexported fields
}
SQLConnection represents a database connection used for migration.
func NewMySQLConnection ¶
func NewMySQLConnection(config *SQLConfig, migrationsDir string) (connection *SQLConnection, err error)
NewMySQLConnection creates a new database connection for MySQL.
func (*SQLConnection) CloseMySQLConnection ¶
func (c *SQLConnection) CloseMySQLConnection() error
CloseMySQLConnection closes the database connection.
Click to show internal directories.
Click to hide internal directories.