Documentation
¶
Index ¶
- Constants
- func VersionedSchemaName(schema string, version string) string
- type MigrationHooks
- type Option
- func WithBackfillBatchDelay(delay time.Duration) Option
- func WithBackfillBatchSize(batchSize int) Option
- func WithDisableViewsManagement() Option
- func WithLockTimeoutMs(lockTimeoutMs int) Option
- func WithMigrationHooks(hooks MigrationHooks) Option
- func WithNoVersionSchemaForRawSQL() Option
- func WithRole(role string) Option
- func WithSQLTransformer(transformer migrations.SQLTransformer) Option
- func WithSearchPath(schemas ...string) Option
- type PGVersion
- type Roll
- func (m *Roll) Close() error
- func (m *Roll) Complete(ctx context.Context) error
- func (m *Roll) Init(ctx context.Context) error
- func (m *Roll) PGVersion() PGVersion
- func (m *Roll) PgConn() db.DB
- func (m *Roll) Rollback(ctx context.Context) error
- func (m *Roll) Schema() string
- func (m *Roll) Start(ctx context.Context, migration *migrations.Migration, ...) error
- func (m *Roll) StartDDLOperations(ctx context.Context, migration *migrations.Migration, ...) ([]*schema.Table, error)
- func (m *Roll) Status(ctx context.Context, schema string) (*state.Status, error)
Constants ¶
const ( PGVersion15 PGVersion = 15 DefaultBackfillBatchSize int = 1000 DefaultBackfillDelay time.Duration = 0 )
Variables ¶
This section is empty.
Functions ¶
func VersionedSchemaName ¶
Types ¶
type MigrationHooks ¶ added in v0.6.0
type MigrationHooks struct {
// BeforeStartDDL is called before the DDL phase of migration start
BeforeStartDDL func(*Roll) error
// AfterStartDDL is called after the DDL phase of migration start is complete
AfterStartDDL func(*Roll) error
// BeforeCompleteDDL is called before the DDL phase of migration complete
BeforeCompleteDDL func(*Roll) error
// AfterCompleteDDL is called after the DDL phase of migration complete is complete
AfterCompleteDDL func(*Roll) error
}
MigrationHooks defines hooks that can be set to be called at various points during the migration process
type Option ¶ added in v0.5.0
type Option func(*options)
func WithBackfillBatchDelay ¶ added in v0.7.0
WithBackfillBatchDelay sets the delay after each batch is run.
func WithBackfillBatchSize ¶ added in v0.7.0
WithBackfillBatchSize sets the number of rows backfilled in each batch.
func WithDisableViewsManagement ¶ added in v0.5.0
func WithDisableViewsManagement() Option
WithDisableViewsManagement disables pgroll version schemas management when passed, pgroll will not create or drop version schemas
func WithLockTimeoutMs ¶ added in v0.5.0
WithLockTimeoutMs sets the lock timeout in milliseconds for pgroll DDL operations
func WithMigrationHooks ¶ added in v0.6.0
func WithMigrationHooks(hooks MigrationHooks) Option
WithMigrationHooks sets the migration hooks for the Roll instance Migration hooks are called at various points during the migration process to allow for custom behavior to be injected
func WithNoVersionSchemaForRawSQL ¶ added in v0.7.0
func WithNoVersionSchemaForRawSQL() Option
WithNoVersionSchemaForRawSQL disables the creation of version schema for raw SQL migrations
func WithSQLTransformer ¶ added in v0.6.0
func WithSQLTransformer(transformer migrations.SQLTransformer) Option
WithSQLTransformer sets the SQL transformer to apply to all user-defined SQL statements before they are executed. This is useful to sanitize or modify user defined SQL statements before they are executed.
func WithSearchPath ¶ added in v0.7.0
WithSearchPath sets the search_path to use during migration execution. The schema in which the migration is run is always included in the search path, regardless of this setting.
type Roll ¶
type Roll struct {
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, pgURL, schema string, state *state.State, opts ...Option) (*Roll, error)
New creates a new Roll instance
func (*Roll) Start ¶
func (m *Roll) Start(ctx context.Context, migration *migrations.Migration, cbs ...migrations.CallbackFn) error
Start will apply the required changes to enable supporting the new schema version
func (*Roll) StartDDLOperations ¶ added in v0.6.0
func (m *Roll) StartDDLOperations(ctx context.Context, migration *migrations.Migration, cbs ...migrations.CallbackFn) ([]*schema.Table, error)
StartDDLOperations performs the DDL operations for the migration. This does not include running backfills for any modified tables.