summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-07-19 09:09:15 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-07-19 09:09:15 +0000
commitfca7a77a23ac6e1723a6449287f731634d735b23 (patch)
treebe38574351cde1b0121630517693efeeaba48aef /lib
parent045e4de472b70754070f63abdf1f6a8397432435 (diff)
parent6f26f6f79f33fdb7e4e556b7f6b37999b78cd323 (diff)
downloadgitlab-ce-fca7a77a23ac6e1723a6449287f731634d735b23.tar.gz
Merge branch 'bvl-free-system-namespace' into 'master'
Free `system` namespace by moving uploads into `uploads/-` Closes #33550 See merge request !12917
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb26
-rw-r--r--lib/gitlab/path_regex.rb1
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb b/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb
new file mode 100644
index 00000000000..0881244ed49
--- /dev/null
+++ b/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb
@@ -0,0 +1,26 @@
+module Gitlab
+ module BackgroundMigration
+ class MigrateSystemUploadsToNewFolder
+ include Gitlab::Database::MigrationHelpers
+ attr_reader :old_folder, :new_folder
+
+ class Upload < ActiveRecord::Base
+ self.table_name = 'uploads'
+ include EachBatch
+ end
+
+ def perform(old_folder, new_folder)
+ replace_sql = replace_sql(uploads[:path], old_folder, new_folder)
+ affected_uploads = Upload.where(uploads[:path].matches("#{old_folder}%"))
+
+ affected_uploads.each_batch do |batch|
+ batch.update_all("path = #{replace_sql}")
+ end
+ end
+
+ def uploads
+ Arel::Table.new('uploads')
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/path_regex.rb b/lib/gitlab/path_regex.rb
index d81f825ef96..60a32d5d5ea 100644
--- a/lib/gitlab/path_regex.rb
+++ b/lib/gitlab/path_regex.rb
@@ -49,7 +49,6 @@ module Gitlab
sent_notifications
services
snippets
- system
teams
u
unicorn_test