Skip to content

Automate post-deployment steps (Feature Flags & Data Migrations)#6195

Merged
jhenderson merged 3 commits intonextfrom
add-data-migration-gem
Mar 10, 2026
Merged

Automate post-deployment steps (Feature Flags & Data Migrations)#6195
jhenderson merged 3 commits intonextfrom
add-data-migration-gem

Conversation

@jhenderson
Copy link
Copy Markdown
Contributor

@jhenderson jhenderson commented Mar 5, 2026

Context

This PR introduces automation for our post-deployment steps to ensure that database migrations and feature flag toggles are executed consistently as part of our deployment pipeline.

Currently, we rely on manual execution of these steps after a release. We have recently experienced incidents where feature flags were accidentally left disabled.

Ticket: MAV-4101

What’s changed

  • Add data_migrate gem to support running data migrations in the deployment workflow
  • Update deploy.yml to run the data migrations in a post-deploy job
  • Took the opportunity to backfill a new column NotifyLogEntry#purpose using this gem instead of having to do it manually

What the logging should look like on CloudWatch

Rails -- { event: "data_migration_start", migration: "BackfillPurposeForNotifyLogEntries", total_records: 10, total_batches: 1 }

Rails -- { event: "data_migration_batch", migration: "BackfillPurposeForNotifyLogEntries", records_updated: 10, batch_size: 1000, batch_processed: 1, total_batches: 1 }

Rails -- { event: "data_migration_finish", migration: "BackfillPurposeForNotifyLogEntries", duration_minutes: 0, total_records: 10, records_updated: 10 }

Data replication test results

It took 51 minutes to complete the data migration.

@jhenderson jhenderson requested a review from a team as a code owner March 5, 2026 09:10
@jhenderson jhenderson added the data consistency Validations and data tweaks label Mar 5, 2026
Comment thread .github/workflows/deploy.yml Outdated
Comment thread db/data_migrate/.keep Outdated
@jhenderson jhenderson force-pushed the add-data-migration-gem branch from 54d68f5 to df692b3 Compare March 5, 2026 09:38
@thomasleese thomasleese added the infrastructure Related to infrastructure changes label Mar 5, 2026
@jhenderson jhenderson force-pushed the add-data-migration-gem branch 2 times, most recently from ffa0f44 to efca0ff Compare March 5, 2026 11:12
@jhenderson jhenderson force-pushed the add-data-migration-gem branch from efca0ff to 9cec7ba Compare March 5, 2026 13:35
Comment thread .github/workflows/deploy.yml Outdated
Comment thread .github/workflows/deploy.yml Outdated
Comment thread .github/workflows/deploy.yml Outdated
Comment thread .github/workflows/deploy.yml Outdated
Comment thread .github/workflows/deploy.yml Outdated
@jhenderson jhenderson force-pushed the add-data-migration-gem branch 6 times, most recently from 6bd4f8d to 695042f Compare March 6, 2026 09:39
@thomasleese thomasleese modified the milestones: v7.2.0, v7.3.0 Mar 6, 2026
@jhenderson jhenderson force-pushed the add-data-migration-gem branch 6 times, most recently from a3179e3 to 373a7c0 Compare March 9, 2026 10:35
Comment thread .github/workflows/deploy.yml Outdated
@jhenderson jhenderson force-pushed the add-data-migration-gem branch 3 times, most recently from 43303be to da77ea3 Compare March 10, 2026 16:15
We sometimes forget to enable the feature flag required for data migrations.
Adding the data_migrate gem lets us run data migrations automatically as part
of the GitHub deployment workflow, giving better visibility into
migration/deployment progress.

Also avoids needing to request console access to run data migrations manually.

Jira-Issue: MAV-4101
…igrate gem

Taking the opportunity to backfill a column using this gem instead of having to
do it manually.

Jira-Issue: MAV-4101
Now that this backfill is moved into a data migration, we can remove
the manual version.

Jira-Issue: MAV-4101
@jhenderson jhenderson force-pushed the add-data-migration-gem branch from da77ea3 to 7274b76 Compare March 10, 2026 16:51
@jhenderson jhenderson merged commit b21459b into next Mar 10, 2026
13 checks passed
@jhenderson jhenderson deleted the add-data-migration-gem branch March 10, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data consistency Validations and data tweaks infrastructure Related to infrastructure changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants