summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2019-07-12 12:59:38 +0000
committerJan Provaznik <jprovaznik@gitlab.com>2019-07-12 12:59:38 +0000
commit907154957ef89c1f0df1de3c665418146cc93f98 (patch)
treea78292af3d7f93f943133c36b29647a7cdf04dcd /db
parentfd407d065861b092dfc4f53ef76ab44991998753 (diff)
parent82e6ed310b1bb5e7faf44742defaf65b74926195 (diff)
downloadgitlab-ce-907154957ef89c1f0df1de3c665418146cc93f98.tar.gz
Merge branch 'bvl-rename-routes-after-user-rename' into 'master'
Set the name of a user-namespace to the user name See merge request gitlab-org/gitlab-ce!23272
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20190628191740_schedule_fixing_names_of_user_namespaces.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/db/post_migrate/20190628191740_schedule_fixing_names_of_user_namespaces.rb b/db/post_migrate/20190628191740_schedule_fixing_names_of_user_namespaces.rb
new file mode 100644
index 00000000000..8fa7068b957
--- /dev/null
+++ b/db/post_migrate/20190628191740_schedule_fixing_names_of_user_namespaces.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class ScheduleFixingNamesOfUserNamespaces < ActiveRecord::Migration[5.1]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ class Namespace < ActiveRecord::Base
+ include ::EachBatch
+
+ self.table_name = 'namespaces'
+
+ scope :user_namespaces, -> { where(type: nil) }
+ end
+
+ class Route < ActiveRecord::Base
+ include ::EachBatch
+
+ self.table_name = 'routes'
+
+ scope :project_routes, -> { where(source_type: 'Project') }
+ end
+
+ disable_ddl_transaction!
+
+ def up
+ queue_background_migration_jobs_by_range_at_intervals(
+ ScheduleFixingNamesOfUserNamespaces::Namespace.user_namespaces,
+ 'FixUserNamespaceNames',
+ 60.seconds,
+ batch_size: 5000
+ )
+
+ queue_background_migration_jobs_by_range_at_intervals(
+ ScheduleFixingNamesOfUserNamespaces::Route.project_routes,
+ 'FixUserProjectRouteNames',
+ 60.seconds,
+ batch_size: 5000
+ )
+ end
+
+ def down
+ # no-op
+ end
+end