Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateSchemaMigrations ¶ added in v0.0.38
func CreateSchemaMigrations(c *pop.Connection) error
CreateSchemaMigrations sets up a table to track migrations. This is an idempotent operation.
Types ¶
type DumpMigrator ¶
func NewDumpMigrator ¶
type Migration ¶ added in v0.0.38
type Migration struct { // Path to the migration (./migrations/123_create_widgets.up.sql) Path string // Version of the migration (123) Version string // Name of the migration (create_widgets) Name string // Direction of the migration (up) Direction string // Type of migration (sql) Type string // DB type (all|postgres|mysql...) DBType string // Runner function to run/execute the migration Runner func(mf Migration) ([]MigrationTuple, error) }
Migration handles the data for a given database migration
func (Migration) Run ¶ added in v0.0.38
func (mf Migration) Run() ([]MigrationTuple, error)
Run the migration. Returns an error if there is no mf.Runner defined.
type MigrationTuple ¶ added in v0.0.38
type Migrations ¶ added in v0.0.38
type Migrations []Migration
Migrations is a collection of Migration
func (*Migrations) Filter ¶ added in v0.0.38
func (mfs *Migrations) Filter(f func(mf Migration) bool)
func (Migrations) Len ¶ added in v0.0.38
func (mfs Migrations) Len() int
func (Migrations) Less ¶ added in v0.0.38
func (mfs Migrations) Less(i, j int) bool
func (Migrations) Swap ¶ added in v0.0.38
func (mfs Migrations) Swap(i, j int)
type Migrator ¶ added in v0.0.38
type Migrator struct { Connection *pop.Connection SchemaPath string Migrations map[string]Migrations // contains filtered or unexported fields }
Migrator forms the basis of all migrations systems. It does the actual heavy lifting of running migrations. When building a new migration system, you should embed this type into your migrator.
func NewMigrator ¶ added in v0.0.38
NewMigrator returns a new "blank" migrator. It is recommended to use something like MigrationBox or FileMigrator. A "blank" Migrator should only be used as the basis for a new type of migration system.
func (Migrator) CreateSchemaMigrations ¶ added in v0.0.38
CreateSchemaMigrations sets up a table to track migrations. This is an idempotent operation.
func (Migrator) Down ¶ added in v0.0.38
Down runs pending "down" migrations and rolls back the database by the specified number of steps.
func (Migrator) DumpMigrationSchema ¶ added in v0.0.38
DumpMigrationSchema will generate a file of the current database schema based on the value of Migrator.SchemaPath
func (Migrator) Reset ¶ added in v0.0.38
Reset the database by running the down migrations followed by the up migrations.
func (Migrator) Status ¶ added in v0.0.38
Status prints out the status of applied/pending migrations.