diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-07-02 13:06:38 +0200 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-07-03 21:21:36 +0200 |
commit | e33c95cf960e6e572dae17e17c4a94fbd5bd4d51 (patch) | |
tree | c821334c23595cb9e5a2f8bb84bbfb648c38ca98 /db | |
parent | acc6e3a0fdb8f710d77b8faa2a39823f7e1c7e5d (diff) | |
download | gitlab-ce-e33c95cf960e6e572dae17e17c4a94fbd5bd4d51.tar.gz |
Migration which fixes cross-project label references
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb | 30 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 31 insertions, 1 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 diff --git a/db/schema.rb b/db/schema.rb index 384a1ec6d37..ea355921bcf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180629191052) do +ActiveRecord::Schema.define(version: 20180702120647) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" |