Documentation ¶
Index ¶
- Constants
- Variables
- func Migrate(db *gorm.DB) error
- func MigrateDown(db *gorm.DB) error
- func MigrateDownFrom(db *gorm.DB, name string) error
- func MigrateUp(db *gorm.DB, to string) error
- func Rollback(db *gorm.DB, m *Migration) error
- type DuplicatedIDError
- type Gormigrate
- type InitSchemaFunc
- type MigrateFunc
- type Migration
- type Options
- type ReservedIDError
- type RollbackFunc
Constants ¶
const ( // MaxIndividualMigrationTime is the maximum amount of time a single // migration is allowed to take before declaring it a failure MaxIndividualMigrationTime = 5 * time.Minute )
Variables ¶
var ( // DefaultOptions can be used if you don't want to think about options. DefaultOptions = &Options{ TableName: "migrations", IDColumnName: "id", IDColumnSize: 255, ValidateUnknownMigrations: false, } // ErrRollbackImpossible is returned when trying to rollback a migration // that has no rollback function. ErrRollbackImpossible = errors.New("gormigrate: It's impossible to rollback this migration") // ErrNoMigrationDefined is returned when no migration is defined. ErrNoMigrationDefined = errors.New("gormigrate: No migration defined") // ErrMissingID is returned when the ID od migration is equal to "" ErrMissingID = errors.New("gormigrate: Missing ID in migration") // ErrNoRunMigration is returned when any run migration was found while // running RollbackLast ErrNoRunMigration = errors.New("gormigrate: Could not find last run migration") // ErrMigrationIDDoesNotExist is returned when migrating or rolling back to a migration ID that // does not exist in the list of migrations ErrMigrationIDDoesNotExist = errors.New("gormigrate: Tried to migrate to an ID that doesn't exist") // ErrUnknownPastMigration is returned if a migration exists in the DB that doesn't exist in the code ErrUnknownPastMigration = errors.New("gormigrate: Found migration in DB that does not exist in code") )
var Migrations []*Migration
Functions ¶
func MigrateDown ¶
Types ¶
type DuplicatedIDError ¶
type DuplicatedIDError struct {
ID string
}
DuplicatedIDError is returned when more than one migration have the same ID
func (*DuplicatedIDError) Error ¶
func (e *DuplicatedIDError) Error() string
type Gormigrate ¶
type Gormigrate struct {
// contains filtered or unexported fields
}
Gormigrate represents a collection of all migrations of a database schema.
func New ¶
func New(db *gorm.DB, options *Options, migrations []*Migration) *Gormigrate
New returns a new Gormigrate.
func (*Gormigrate) Migrate ¶
func (g *Gormigrate) Migrate() error
Migrate executes all migrations that did not run yet.
func (*Gormigrate) MigrateTo ¶
func (g *Gormigrate) MigrateTo(migrationID string) error
MigrateTo executes all migrations that did not run yet up to the migration that matches `migrationID`.
func (*Gormigrate) RollbackLast ¶
func (g *Gormigrate) RollbackLast() error
RollbackLast undo the last migration
func (*Gormigrate) RollbackMigration ¶
func (g *Gormigrate) RollbackMigration(migration *Migration) error
RollbackMigration rolls back a migration.
func (*Gormigrate) RollbackTo ¶
func (g *Gormigrate) RollbackTo(migrationID string) error
RollbackTo undoes migrations up to the given migration that matches the `migrationID`. Migration with the matching `migrationID` is not rolled back.
type InitSchemaFunc ¶
InitSchemaFunc is the func signature for initializing the schema.
type MigrateFunc ¶
MigrateFunc is the func signature for migrating.
type Migration ¶
type Migration struct { // ID is the migration identifier. Usually a timestamp like "201601021504". ID string // Migrate is a function that will br executed while running this migration. Migrate MigrateFunc // Rollback will be executed on rollback. Can be nil. Rollback RollbackFunc // DisableTransaction disables wrapping the migration in a transaction. Useful in // very rare cases, be careful because it can leave the database in an // inconsistent state DisableTransaction bool }
Migration represents a database migration (a modification to be made on the database).
type Options ¶
type Options struct { // TableName is the migration table. TableName string // IDColumnName is the name of column where the migration id will be stored. IDColumnName string // IDColumnSize is the length of the migration id column IDColumnSize int // ValidateUnknownMigrations will cause migrate to fail if there's unknown migration // IDs in the database ValidateUnknownMigrations bool }
Options define options for all migrations.
type ReservedIDError ¶
type ReservedIDError struct {
ID string
}
ReservedIDError is returned when a migration is using a reserved ID
func (*ReservedIDError) Error ¶
func (e *ReservedIDError) Error() string
type RollbackFunc ¶
RollbackFunc is the func signature for rollbacking.
Source Files ¶
- 0001_initial.go
- 0002_gormv2.go
- 0003_eth_logs_table.go
- 0004_cleanup_tx_attempt_state.go
- 0005_tx_attempts_insufficient_eth_index.go
- 0006_unique_task_specs_per_pipeline_run.go
- 0007_reverse_eth_logs_table.go
- 0008_reapply_eth_logs_table.go
- 0009_add_min_payment_to_flux_monitor_spec.go
- 0010_bridge_fk.go
- 0011_latest_round_requested.go
- 0012_change_jobs_to_numeric.go
- 0013_create_flux_monitor_round_stats_v2.go
- 0014_add_keeper_tables.go
- 0015_simplify_log_broadcaster.go
- 0016_pipeline_task_run_dot_id.go
- 0017_bptxm_chain_nonce_fastforward.go
- 0018_add_node_version_table.go
- 0019_last_run_height_column_to_keeper_table.go
- 0020_remove_result_task.go
- 0021_add_job_id_topic_filter.go
- 0022_unfinished_pipeline_task_run_idx.go
- 0023_add_confirmations_to_direct_request.go
- migrate.go
- migration_helper.go