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 Job36
- 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 ¶ added in v1.10.16
Types ¶
type DuplicatedIDError ¶ added in v1.10.16
type DuplicatedIDError struct {
ID string
}
DuplicatedIDError is returned when more than one migration have the same ID
func (*DuplicatedIDError) Error ¶ added in v1.10.16
func (e *DuplicatedIDError) Error() string
type Gormigrate ¶ added in v1.10.16
type Gormigrate struct {
// contains filtered or unexported fields
}
Gormigrate represents a collection of all migrations of a database schema.
func New ¶ added in v1.10.16
func New(db *gorm.DB, options *Options, migrations []*Migration) *Gormigrate
New returns a new Gormigrate.
func (*Gormigrate) Migrate ¶ added in v1.10.16
func (g *Gormigrate) Migrate() error
Migrate executes all migrations that did not run yet.
func (*Gormigrate) MigrateTo ¶ added in v1.10.16
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 ¶ added in v1.10.16
func (g *Gormigrate) RollbackLast() error
RollbackLast undo the last migration
func (*Gormigrate) RollbackMigration ¶ added in v1.10.16
func (g *Gormigrate) RollbackMigration(migration *Migration) error
RollbackMigration rolls back a migration.
func (*Gormigrate) RollbackTo ¶ added in v1.10.16
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 ¶ added in v1.10.16
InitSchemaFunc is the func signature for initializing the schema.
type Job36 ¶ added in v1.10.16
type Job36 struct { ID int32 `toml:"-" gorm:"primary_key"` ExternalJobID uuid.UUID `toml:"externalJobID"` OffchainreportingOracleSpecID *int32 CronSpecID *int32 DirectRequestSpecID *int32 FluxMonitorSpecID *int32 KeeperSpecID *int32 VRFSpecID *int32 WebhookSpecID *int32 PipelineSpecID int32 Type string SchemaVersion uint32 Name null.String MaxTaskDuration models.Interval }
Copy this here to avoid a direct job.Job reference which could change and break the migration.
type MigrateFunc ¶ added in v1.10.16
MigrateFunc is the func signature for migrating.
type Migration ¶ added in v1.10.16
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 ¶ added in v1.10.16
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 ¶ added in v1.10.16
type ReservedIDError struct {
ID string
}
ReservedIDError is returned when a migration is using a reserved ID
func (*ReservedIDError) Error ¶ added in v1.10.16
func (e *ReservedIDError) Error() string
type RollbackFunc ¶ added in v1.10.16
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
- 0024_add_cron_spec_tables.go
- 0025_create_log_config_table.go
- 0026_eth_tx_meta.go
- 0027_cascade_ocr_latest_round_request.go
- 0028_vrf_v2.go
- 0029_add_webhook_spec_tables.go
- 0030_drop_keys_last_used.go
- 0031_eth_tx_trigger_with_key_address.go
- 0032_rename_direct_request_specs_num_confirmations.go
- 0033_flux_monitor_round_stats_fk_index.go
- 0034_webhook_external_initiator.go
- 0035_create_feeds_managers.go
- 0036_external_job_id.go
- 0037_cascade_deletes.go
- 0038_create_csa_keys.go
- 0039_remove_fmv2_precision.go
- 0040_heads_l1_block_number.go
- 0041_eth_tx_strategies.go
- 0042_create_job_proposals.go
- 0043_gas_limit_on_eth_tx_attempts.go
- 0044_create_table_ocr_discoverer_database.go
- 0045_add_uuid_to_pipeline_task_runs.go
- 0046_add_fmv2_drumbeat_ticker.go
- 0047_add_uuid_to_job_proposals.go
- 0048_add_ocr_bootstrap_node_to_feeds_manager.go
- 0049_rename_job_id_to_external_job_id_in_job_proposals.go
- 0050_add_ocr_bootstrap_fields_to_feeds_managers.go
- 0051_webhook_specs_external_initiators_join.go
- 0052_not_null_job_pipeline_spec_id.go
- 0053_add_fmv2_drumbeat_random_delay.go
- 0058_direct_request_whitelist.go
- 0059_direct_request_whitelist_min_contract_payment.go
- migrate.go
- migration_helper.go