Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MigrationHooks API to allow custom behaviour during migration start #290

Merged
merged 8 commits into from
Feb 29, 2024

Conversation

andrew-farries
Copy link
Collaborator

Add two new migration options:

  • WithSettingsOnMigrationStart: defines a map of Postgres setting/value pairs to be set for the duration of the DDL phase of migration start. Settings will be restored to their previous values once the DDL phase is complete.
  • WithKickstartReplication: defines an option that when set will make a no-op schema change in between completing the DDL operations for migration start and performing backfills. This can be used to ensure that schema replication is up-to-date before starting backfills.

Neither of these options are exposed via the CLI; they are intended for use by pgroll integrators, ie modules using pgroll as a Go dependency.

pkg/roll/execute.go Outdated Show resolved Hide resolved
Base automatically changed from backfill-after-ddl-operations to main February 29, 2024 06:39
andrew-farries added a commit that referenced this pull request Feb 29, 2024
Separate the DDL operations required during migration start from the DML
operations (backfills). Complete all DDL steps before starting DML.

Each `Start` operation returns the name of the table that requires
backfill, if any. After all operations have started, backfills are run
on each table that requires one.

Separating DDL and DML during migration start like this will allow for
setting Postgres options that should apply only for the DDL phase of
migration start (as in #290).
Add an option to allow a specific Postgres setting to be enabled on
migration start.

This is useful when a migration requires a setting to be enabled for the
duration of the start operation. The setting will be disabled after the
migration start phase has finished.
@andrew-farries andrew-farries force-pushed the enable-setting-on-migration-start branch from aceeb19 to 49e738c Compare February 29, 2024 06:40
Allow a `Roll` to take migration hooks to be executed at various points
in the migration.
Check that the hooks are invoked.
@andrew-farries andrew-farries merged commit c08ef70 into main Feb 29, 2024
63 checks passed
@andrew-farries andrew-farries deleted the enable-setting-on-migration-start branch February 29, 2024 08:54
@andrew-farries andrew-farries changed the title Add two new options to help with replication control Add MigrationHooks API to allow custom behaviour during migration start Feb 29, 2024
This was referenced Mar 1, 2024
andrew-farries added a commit that referenced this pull request Mar 7, 2024
Remove the `BeforeBackfill` hook.

The `BeforeBackfill` hook was added along with the `BeforeStartDDL` and
`AfterStartDDL` hooks in #290, but is of limited use as a hook that runs
only after successful execution of start phase DDL. Prefer a simpler API
with fewer hooks until there is a demonstrated need for it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants