Documentation ¶
Index ¶
- Variables
- type Config
- type GoMigrate
- func (g *GoMigrate) Close() error
- func (g *GoMigrate) Cmd() *cli.Command
- func (g *GoMigrate) Create(tables []*schema.Table) error
- func (g *GoMigrate) List() ([]*MigrationWrap, error)
- func (g *GoMigrate) Migrate() error
- func (g *GoMigrate) MigrateTo(name string) error
- func (g *GoMigrate) RollbackLast() error
- func (g *GoMigrate) RollbackTo(name string) error
- type MigrateFunc
- type Migration
- type MigrationWrap
- type RollbackFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultConfig = Config{
TableName: "migrations",
ColumnName: "id",
ColumnSize: 255,
MigrationPath: "./internal/schema/migrations",
}
DefaultConfig can be used if you don't want to think about config.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // TableName is the migration table. TableName string `yaml:"table_name"` // ColumnName is the name of column where the migration id will be stored. ColumnName string `yaml:"column_name"` // ColumnSize is the length of the migration id column ColumnSize int `yaml:"column_size"` MigrationPath string `yaml:"sql_path"` }
Config define config for all migrations.
type GoMigrate ¶
type GoMigrate struct {
// contains filtered or unexported fields
}
GoMigrate represents a collection of all migrations of a database schema.
func New ¶
func New(db *entsql.Driver, cfg *Config, migrations []*Migration, tables []*schema.Table) *GoMigrate
New returns a new GoMigrate.
func (*GoMigrate) List ¶
func (g *GoMigrate) List() ([]*MigrationWrap, error)
func (*GoMigrate) RollbackLast ¶
RollbackLast undo the last migration
func (*GoMigrate) RollbackTo ¶
RollbackTo undoes migrations up to the given migration that matches the `migrationID`. Migration with the matching `name` is not rolled back.
type MigrateFunc ¶
MigrateFunc is the func signature for migrating.
type Migration ¶
type Migration struct { Name string Description string MigrationSql string // DataMigrate is a function that will br executed while running this migration. DataMigrate MigrateFunc // DataRollback will be executed on rollback. Can be nil. DataRollback RollbackFunc }
Migration represents a database migration
type MigrationWrap ¶
Click to show internal directories.
Click to hide internal directories.