Skip to content
Snippets Groups Projects

Docs for marking a batched BG migration finished

Merged Adam Hegyi requested to merge ah-marking-bg-migration-finished-doc into master
All threads resolved!
@@ -336,19 +336,19 @@ When the background migration is determined to be "safe" to skip, the migration
@@ -336,19 +336,19 @@ When the background migration is determined to be "safe" to skip, the migration
WARNING:
WARNING:
Make sure you create a backup before proceeding.
Make sure you create a backup before proceeding.
```shell
```ruby
# Start the rails console
# Start the rails console
connection = ApplicationRecord.connection # or Ci::ApplicationRecord.connection, depending on which DB was the migration scheduled
connection = ApplicationRecord.connection # or Ci::ApplicationRecord.connection, depending on which DB was the migration scheduled
Gitlab::Database::SharedModel.using_connection(connection) do
Gitlab::Database::SharedModel.using_connection(connection) do
migration = Gitlab::Database::BackgroundMigration::BatchedMigration.for_configuration(
migration = Gitlab::Database::BackgroundMigration::BatchedMigration.find_for_configuration(
:gitlab_main, # or :gitlab_ci
Gitlab::Database.gitlab_schemas_for_connection(connection),
'BackfillUserDetailsFields',
'BackfillUserDetailsFields',
:users,
:users,
:id,
:id,
[]
[]
).first!
)
# mark all jobs completed
# mark all jobs completed
migration.batched_jobs.update_all(status: Gitlab::Database::BackgroundMigration::BatchedJob.state_machine.states['succeeded'].value)
migration.batched_jobs.update_all(status: Gitlab::Database::BackgroundMigration::BatchedJob.state_machine.states['succeeded'].value)
Loading