summaryrefslogtreecommitdiff
path: root/db/migrate/20161130095245_fill_routes_table.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-10-31 13:00:53 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-12-08 11:47:16 +0200
commit83232be0e14cc8b35bf74532203a6e4371c15e70 (patch)
treed6cde69809c44055496954efe57b866404b3d0f2 /db/migrate/20161130095245_fill_routes_table.rb
parent34fc5b050a4e70bf491be9a49cfa2dc0a7a9a9a2 (diff)
downloadgitlab-ce-83232be0e14cc8b35bf74532203a6e4371c15e70.tar.gz
Add nested groups support on data leveldz-nested-groups
* add parent_id field to namespaces table to store relation with nested groups * create routes table to keep information about full path of every group and project * project/group lookup by full path from routes table Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'db/migrate/20161130095245_fill_routes_table.rb')
-rw-r--r--db/migrate/20161130095245_fill_routes_table.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/db/migrate/20161130095245_fill_routes_table.rb b/db/migrate/20161130095245_fill_routes_table.rb
new file mode 100644
index 00000000000..6754e583000
--- /dev/null
+++ b/db/migrate/20161130095245_fill_routes_table.rb
@@ -0,0 +1,21 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class FillRoutesTable < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = true
+ DOWNTIME_REASON = 'No new namespaces should be created during data copy'
+
+ def up
+ execute <<-EOF
+ INSERT INTO routes
+ (source_id, source_type, path)
+ (SELECT id, 'Namespace', path FROM namespaces)
+ EOF
+ end
+
+ def down
+ Route.delete_all(source_type: 'Namespace')
+ end
+end