Skip to content

Add queued_migration_version to facilitate BBM dependencies

Prabakaran Murugesan requested to merge 424881-attrs-for-bbm-dependencies into master

What does this MR do and why?

This adds queued_migration_version attr to batched_background_migrations table, which will be used by later migrations to establish the dependencies.

More details can be found in #424881 (closed)'s description.

Rationale for choosing migration version:

Version of the migration which enqueued the BBM has been chosen as the unique key for each batched_background_migration, so that it'll be easier to establish the dependencies (instead of mentioning all columns in the existing uniq index) while writing future migrations.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. Run migrations to create the necessary attribute AddQueuedMigrationVersionToBatchedBackgroundMigrations and AddLimitToQueuedMigrationVersionInBatchedBackgroundMigrations.

  2. Enqueue a dummy batched background migration

    bundle exec rails g batched_background_migration dummy_batched_migration --table_name=projects --column_name=id --feature_category=database

  3. The post migration which calls queue_batched_background_migration should have the correct queued_migration_version value specified.

  4. On running the created dummy migration locally, queued_migration_version attr will get saved in the batched_background_migrations record.

    bbm = Gitlab::Database::BackgroundMigration::BatchedMigration.last
    bbm.queued_migration_version

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #424881 (closed)

Edited by Prabakaran Murugesan

Merge request reports

Loading