summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2018-11-20 12:48:18 +0100
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2018-11-27 13:41:46 +0100
commitfff7754186202cfcdeaa0962c28e5d43ddd705b7 (patch)
treebba449dc8386ce9a6ebd951d6a1291b1671cb7b5 /db/migrate
parent397fd09ac4ba7353580f4d3a88c80105d51ff47a (diff)
downloadgitlab-ce-fff7754186202cfcdeaa0962c28e5d43ddd705b7.tar.gz
Rename the Repository table to PoolRepository
To separate the different kinds of repositories we have at GitLab this table will be renamed to pool_repositories. A project can, for now at least, be member of none, or one of these. The table will get additional columns in a later merge request where more logic is implemented for the model. Further included is a small refactor of logic around hashing ids for the disk_path, mainly to ensure a previous implementation is reusable. The disk_path for the pool_repositories table no longer has a NOT NULL constraint, but given the hashing of the ID requires the DB to assign the record an ID, an after_create hook is used to update the value. A related MR is: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23143, adding tables for 'normal' repositories and wiki_repositories.
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20181120082911_rename_repositories_pool_repositories.rb11
-rw-r--r--db/migrate/20181123135036_drop_not_null_constraint_pool_repository_disk_path.rb9
2 files changed, 20 insertions, 0 deletions
diff --git a/db/migrate/20181120082911_rename_repositories_pool_repositories.rb b/db/migrate/20181120082911_rename_repositories_pool_repositories.rb
new file mode 100644
index 00000000000..165771c4775
--- /dev/null
+++ b/db/migrate/20181120082911_rename_repositories_pool_repositories.rb
@@ -0,0 +1,11 @@
+class RenameRepositoriesPoolRepositories < ActiveRecord::Migration[5.0]
+ include Gitlab::Database::MigrationHelpers
+
+ # This change doesn't require downtime as the table is not in use, so we're
+ # free to change an empty table
+ DOWNTIME = false
+
+ def change
+ rename_table :repositories, :pool_repositories
+ end
+end
diff --git a/db/migrate/20181123135036_drop_not_null_constraint_pool_repository_disk_path.rb b/db/migrate/20181123135036_drop_not_null_constraint_pool_repository_disk_path.rb
new file mode 100644
index 00000000000..bcd969e91c5
--- /dev/null
+++ b/db/migrate/20181123135036_drop_not_null_constraint_pool_repository_disk_path.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class DropNotNullConstraintPoolRepositoryDiskPath < ActiveRecord::Migration[5.0]
+ DOWNTIME = false
+
+ def change
+ change_column_null :pool_repositories, :disk_path, true
+ end
+end