summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-07-06 09:31:11 +0000
committerSean McGivern <sean@mcgivern.me.uk>2018-07-06 09:31:11 +0000
commitf5b12225d8ee8686eddeb35b2851d93631f72c89 (patch)
treeae26a99f1244d2b39995bee0b3ec9fc3189217a7 /db
parent68d138e85e3263959700d16eab7d9ab3e883f7f8 (diff)
parent2d2adf42e35c5e96850d9421afc87e1f93eed108 (diff)
downloadgitlab-ce-f5b12225d8ee8686eddeb35b2851d93631f72c89.tar.gz
Merge branch 'jprovazn-label-links-update' into 'master'
Fix cross-project label references Closes #45539 See merge request gitlab-org/gitlab-ce!20308
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb30
-rw-r--r--db/schema.rb2
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 c9aaf80f059..8880ecf4f5c 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"