summaryrefslogtreecommitdiff
path: root/doc/development/database/background_migrations.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/development/database/background_migrations.md')
-rw-r--r--doc/development/database/background_migrations.md14
1 files changed, 9 insertions, 5 deletions
diff --git a/doc/development/database/background_migrations.md b/doc/development/database/background_migrations.md
index 1f7e0d76c89..80ba0336bda 100644
--- a/doc/development/database/background_migrations.md
+++ b/doc/development/database/background_migrations.md
@@ -7,7 +7,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Background migrations
WARNING:
-Background migrations are strongly discouraged in favor of the new [batched background migrations framework](../batched_background_migrations.md).
+Background migrations are strongly discouraged in favor of the new [batched background migrations framework](batched_background_migrations.md).
Please check that documentation and determine if that framework suits your needs and fall back
to these only if required.
@@ -45,13 +45,17 @@ into this category.
## Isolation
Background migrations must be isolated and can not use application code (for example,
-models defined in `app/models`). Since these migrations can take a long time to
-run it's possible for new versions to be deployed while they are still running.
+models defined in `app/models` except the `ApplicationRecord` classes). Since these migrations
+can take a long time to run it's possible for new versions to be deployed while they are still running.
It's also possible for different migrations to be executed at the same time.
This means that different background migrations should not migrate data in a
way that would cause conflicts.
+## Accessing data for multiple databases
+
+See [Accessing data for multiple databases of Batched Background Migrations](batched_background_migrations.md#accessing-data-for-multiple-databases) for more details.
+
## Idempotence
Background migrations are executed in a context of a Sidekiq process.
@@ -190,7 +194,7 @@ class:
```ruby
class Gitlab::BackgroundMigration::ExtractIntegrationsUrl
- class Integration < ActiveRecord::Base
+ class Integration < ::ApplicationRecord
self.table_name = 'integrations'
end
@@ -214,7 +218,7 @@ created and updated integrations. We can do this using something along the lines
the following:
```ruby
-class Integration < ActiveRecord::Base
+class Integration < ::ApplicationRecord
after_commit :schedule_integration_migration, on: :update
after_commit :schedule_integration_migration, on: :create