diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-07-02 14:06:38 +0300 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-07-03 22:21:36 +0300 |
commit | e33c95cf960e6e572dae17e17c4a94fbd5bd4d51 (patch) | |
tree | c821334c23595cb9e5a2f8bb84bbfb648c38ca98 /db/post_migrate | |
parent | acc6e3a0fdb8f710d77b8faa2a39823f7e1c7e5d (diff) |
Migration which fixes cross-project label references
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb b/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb new file mode 100644 index 00000000000..59aa41adede --- /dev/null +++ b/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb @@ -0,0 +1,30 @@ +class EnqueueFixCrossProjectLabelLinks < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + BATCH_SIZE = 100 + MIGRATION = 'FixCrossProjectLabelLinks' + DELAY_INTERVAL = 5.minutes + + disable_ddl_transaction! + + class Label < ActiveRecord::Base + self.table_name = 'labels' + end + + class Namespace < ActiveRecord::Base + self.table_name = 'namespaces' + + include ::EachBatch + + default_scope { where(type: 'Group', id: Label.where(type: 'GroupLabel').select('distinct group_id')) } + end + + def up + queue_background_migration_jobs_by_range_at_intervals(Namespace, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE) + end + + def down + # noop + end +end |