summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-20 18:38:24 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-20 18:38:24 +0000
commit983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch)
treeb153cd387c14ba23bd5a07514c7c01fddf6a78a0 /db/migrate
parenta2bddee2cdb38673df0e004d5b32d9f77797de64 (diff)
downloadgitlab-ce-983a0bba5d2a042c4a3bbb22432ec192c7501d82.tar.gz
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20180423204600_add_pages_access_level_to_project_feature.rb4
-rw-r--r--db/migrate/20200406165950_add_not_null_constraint_on_file_store_to_lfs_objects.rb24
-rw-r--r--db/migrate/20200406171857_add_not_null_constraint_on_file_store_to_ci_job_artifacts.rb24
-rw-r--r--db/migrate/20200406172135_add_not_null_constraint_on_file_store_to_uploads.rb24
-rw-r--r--db/migrate/20200407120000_add_push_rule_id_to_groups.rb19
-rw-r--r--db/migrate/20200407121321_add_push_rule_foreign_key_to_groups.rb18
-rw-r--r--db/migrate/20200407171133_add_protected_tag_create_access_levels_user_id_foreign_key.rb34
-rw-r--r--db/migrate/20200407171417_validate_protected_tag_create_access_levels_user_id_foreign_key.rb16
-rw-r--r--db/migrate/20200408133211_add_index_on_route_path_trigram.rb18
-rw-r--r--db/migrate/20200408154331_add_protected_branch_merge_access_levels_user_id_foreign_key.rb34
-rw-r--r--db/migrate/20200408154349_validate_protected_branch_merge_access_levels_user_id_foreign_key.rb16
-rw-r--r--db/migrate/20200408154411_add_path_locks_user_id_foreign_key.rb34
-rw-r--r--db/migrate/20200408154428_validate_path_locks_user_id_foreign_key.rb16
-rw-r--r--db/migrate/20200408154455_add_protected_branch_push_access_levels_user_id_foreign_key.rb34
-rw-r--r--db/migrate/20200408154533_validate_protected_branch_push_access_levels_user_id_foreign_key.rb16
-rw-r--r--db/migrate/20200408154604_add_u2f_registrations_user_id_foreign_key.rb34
-rw-r--r--db/migrate/20200408154624_validate_u2f_registrations_user_id_foreign_key.rb16
-rw-r--r--db/migrate/20200408212219_add_status_page_url_to_status_page_settings.rb18
-rw-r--r--db/migrate/20200409085956_add_partial_index_on_import_failures_retry_count.rb17
-rw-r--r--db/migrate/20200410232012_add_metrics_dashboard_access_level_to_project_feature.rb19
-rw-r--r--db/migrate/20200413072059_add_group_owners_can_manage_default_branch_protection_to_application_settings.rb19
-rw-r--r--db/migrate/20200414144547_remove_index_projects_on_creator_id_and_created_at_from_projects.rb18
-rw-r--r--db/migrate/20200415160722_remove_not_null_lfs_objects_constraint.rb19
-rw-r--r--db/migrate/20200415161021_remove_not_null_ci_job_artifacts_constraint.rb19
-rw-r--r--db/migrate/20200415161206_remove_not_null_uploads_constraint.rb19
-rw-r--r--db/migrate/20200415192656_add_name_regex_keep_to_container_expiration_policies.rb21
-rw-r--r--db/migrate/20200416120128_add_columns_to_terraform_state.rb17
-rw-r--r--db/migrate/20200416120354_add_locked_by_user_id_foreign_key_to_terraform_state.rb19
28 files changed, 514 insertions, 72 deletions
diff --git a/db/migrate/20180423204600_add_pages_access_level_to_project_feature.rb b/db/migrate/20180423204600_add_pages_access_level_to_project_feature.rb
index 0c536f917ce..acb6d04126e 100644
--- a/db/migrate/20180423204600_add_pages_access_level_to_project_feature.rb
+++ b/db/migrate/20180423204600_add_pages_access_level_to_project_feature.rb
@@ -4,11 +4,15 @@ class AddPagesAccessLevelToProjectFeature < ActiveRecord::Migration[4.2]
DOWNTIME = false
+ # rubocop: disable Migration/UpdateLargeTable
+ # rubocop: disable Migration/AddColumnWithDefault
def up
add_column_with_default(:project_features, :pages_access_level, :integer, default: ProjectFeature::PUBLIC, allow_null: false)
change_column_default(:project_features, :pages_access_level, ProjectFeature::ENABLED)
end
+ # rubocop: enable Migration/UpdateLargeTable
+ # rubocop: enable Migration/AddColumnWithDefault
def down
remove_column :project_features, :pages_access_level
diff --git a/db/migrate/20200406165950_add_not_null_constraint_on_file_store_to_lfs_objects.rb b/db/migrate/20200406165950_add_not_null_constraint_on_file_store_to_lfs_objects.rb
deleted file mode 100644
index 78b5832fea4..00000000000
--- a/db/migrate/20200406165950_add_not_null_constraint_on_file_store_to_lfs_objects.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-class AddNotNullConstraintOnFileStoreToLfsObjects < ActiveRecord::Migration[6.0]
- include Gitlab::Database::MigrationHelpers
-
- CONSTRAINT_NAME = 'lfs_objects_file_store_not_null'
- DOWNTIME = false
-
- def up
- with_lock_retries do
- execute <<~SQL
- ALTER TABLE lfs_objects ADD CONSTRAINT #{CONSTRAINT_NAME} CHECK (file_store IS NOT NULL) NOT VALID;
- SQL
- end
- end
-
- def down
- with_lock_retries do
- execute <<~SQL
- ALTER TABLE lfs_objects DROP CONSTRAINT IF EXISTS #{CONSTRAINT_NAME};
- SQL
- end
- end
-end
diff --git a/db/migrate/20200406171857_add_not_null_constraint_on_file_store_to_ci_job_artifacts.rb b/db/migrate/20200406171857_add_not_null_constraint_on_file_store_to_ci_job_artifacts.rb
deleted file mode 100644
index 1d44e5c17b3..00000000000
--- a/db/migrate/20200406171857_add_not_null_constraint_on_file_store_to_ci_job_artifacts.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-class AddNotNullConstraintOnFileStoreToCiJobArtifacts < ActiveRecord::Migration[6.0]
- include Gitlab::Database::MigrationHelpers
-
- CONSTRAINT_NAME = 'ci_job_artifacts_file_store_not_null'
- DOWNTIME = false
-
- def up
- with_lock_retries do
- execute <<~SQL
- ALTER TABLE ci_job_artifacts ADD CONSTRAINT #{CONSTRAINT_NAME} CHECK (file_store IS NOT NULL) NOT VALID;
- SQL
- end
- end
-
- def down
- with_lock_retries do
- execute <<~SQL
- ALTER TABLE ci_job_artifacts DROP CONSTRAINT IF EXISTS #{CONSTRAINT_NAME};
- SQL
- end
- end
-end
diff --git a/db/migrate/20200406172135_add_not_null_constraint_on_file_store_to_uploads.rb b/db/migrate/20200406172135_add_not_null_constraint_on_file_store_to_uploads.rb
deleted file mode 100644
index aa498ba9c89..00000000000
--- a/db/migrate/20200406172135_add_not_null_constraint_on_file_store_to_uploads.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-class AddNotNullConstraintOnFileStoreToUploads < ActiveRecord::Migration[6.0]
- include Gitlab::Database::MigrationHelpers
-
- CONSTRAINT_NAME = 'uploads_store_not_null'
- DOWNTIME = false
-
- def up
- with_lock_retries do
- execute <<~SQL
- ALTER TABLE uploads ADD CONSTRAINT #{CONSTRAINT_NAME} CHECK (store IS NOT NULL) NOT VALID;
- SQL
- end
- end
-
- def down
- with_lock_retries do
- execute <<~SQL
- ALTER TABLE uploads DROP CONSTRAINT IF EXISTS #{CONSTRAINT_NAME};
- SQL
- end
- end
-end
diff --git a/db/migrate/20200407120000_add_push_rule_id_to_groups.rb b/db/migrate/20200407120000_add_push_rule_id_to_groups.rb
new file mode 100644
index 00000000000..4b4e99052aa
--- /dev/null
+++ b/db/migrate/20200407120000_add_push_rule_id_to_groups.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddPushRuleIdToGroups < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_column :namespaces, :push_rule_id, :bigint
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :namespaces, :push_rule_id
+ end
+ end
+end
diff --git a/db/migrate/20200407121321_add_push_rule_foreign_key_to_groups.rb b/db/migrate/20200407121321_add_push_rule_foreign_key_to_groups.rb
new file mode 100644
index 00000000000..acc74b43659
--- /dev/null
+++ b/db/migrate/20200407121321_add_push_rule_foreign_key_to_groups.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddPushRuleForeignKeyToGroups < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :namespaces, :push_rule_id, unique: true
+ add_concurrent_foreign_key :namespaces, :push_rules, column: :push_rule_id, on_delete: :nullify
+ end
+
+ def down
+ remove_foreign_key_if_exists :namespaces, column: :push_rule_id
+ remove_concurrent_index :namespaces, :push_rule_id
+ end
+end
diff --git a/db/migrate/20200407171133_add_protected_tag_create_access_levels_user_id_foreign_key.rb b/db/migrate/20200407171133_add_protected_tag_create_access_levels_user_id_foreign_key.rb
new file mode 100644
index 00000000000..69222710026
--- /dev/null
+++ b/db/migrate/20200407171133_add_protected_tag_create_access_levels_user_id_foreign_key.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+# rubocop: disable Migration/AddConcurrentForeignKey
+# rubocop: disable Migration/WithLockRetriesWithoutDdlTransaction
+class AddProtectedTagCreateAccessLevelsUserIdForeignKey < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ CONSTRAINT_NAME = 'fk_protected_tag_create_access_levels_user_id'
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_foreign_key(:protected_tag_create_access_levels, :users, on_delete: :cascade, validate: false, name: CONSTRAINT_NAME)
+ remove_foreign_key_if_exists(:protected_tag_create_access_levels, column: :user_id, on_delete: nil)
+ end
+ end
+
+ def down
+ fk_exists = foreign_key_exists?(:protected_tag_create_access_levels, :users, column: :user_id, on_delete: nil)
+
+ unless fk_exists
+ with_lock_retries do
+ add_foreign_key(:protected_tag_create_access_levels, :users, column: :user_id, validate: false)
+ end
+ end
+
+ remove_foreign_key_if_exists(:protected_tag_create_access_levels, column: :user_id, name: CONSTRAINT_NAME)
+
+ fk_name = concurrent_foreign_key_name(:protected_tag_create_access_levels, :user_id, prefix: 'fk_rails_')
+ validate_foreign_key(:protected_tag_create_access_levels, :user_id, name: fk_name)
+ end
+end
diff --git a/db/migrate/20200407171417_validate_protected_tag_create_access_levels_user_id_foreign_key.rb b/db/migrate/20200407171417_validate_protected_tag_create_access_levels_user_id_foreign_key.rb
new file mode 100644
index 00000000000..baba65e0b7d
--- /dev/null
+++ b/db/migrate/20200407171417_validate_protected_tag_create_access_levels_user_id_foreign_key.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class ValidateProtectedTagCreateAccessLevelsUserIdForeignKey < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ CONSTRAINT_NAME = 'fk_protected_tag_create_access_levels_user_id'
+
+ def up
+ validate_foreign_key :protected_tag_create_access_levels, :user_id, name: CONSTRAINT_NAME
+ end
+
+ def down
+ # no op
+ end
+end
diff --git a/db/migrate/20200408133211_add_index_on_route_path_trigram.rb b/db/migrate/20200408133211_add_index_on_route_path_trigram.rb
new file mode 100644
index 00000000000..3329252bbd3
--- /dev/null
+++ b/db/migrate/20200408133211_add_index_on_route_path_trigram.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexOnRoutePathTrigram < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_routes_on_path_trigram'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :routes, :path, name: INDEX_NAME, using: :gin, opclass: { path: :gin_trgm_ops }
+ end
+
+ def down
+ remove_concurrent_index_by_name(:routes, INDEX_NAME)
+ end
+end
diff --git a/db/migrate/20200408154331_add_protected_branch_merge_access_levels_user_id_foreign_key.rb b/db/migrate/20200408154331_add_protected_branch_merge_access_levels_user_id_foreign_key.rb
new file mode 100644
index 00000000000..1b31da93fe7
--- /dev/null
+++ b/db/migrate/20200408154331_add_protected_branch_merge_access_levels_user_id_foreign_key.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+# rubocop: disable Migration/AddConcurrentForeignKey
+# rubocop: disable Migration/WithLockRetriesWithoutDdlTransaction
+class AddProtectedBranchMergeAccessLevelsUserIdForeignKey < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ CONSTRAINT_NAME = 'fk_protected_branch_merge_access_levels_user_id'
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_foreign_key(:protected_branch_merge_access_levels, :users, on_delete: :cascade, validate: false, name: CONSTRAINT_NAME)
+ remove_foreign_key_if_exists(:protected_branch_merge_access_levels, column: :user_id, on_delete: nil)
+ end
+ end
+
+ def down
+ fk_exists = foreign_key_exists?(:protected_branch_merge_access_levels, :users, column: :user_id, on_delete: nil)
+
+ unless fk_exists
+ with_lock_retries do
+ add_foreign_key(:protected_branch_merge_access_levels, :users, column: :user_id, validate: false)
+ end
+ end
+
+ remove_foreign_key_if_exists(:protected_branch_merge_access_levels, column: :user_id, name: CONSTRAINT_NAME)
+
+ fk_name = concurrent_foreign_key_name(:protected_branch_merge_access_levels, :user_id, prefix: 'fk_rails_')
+ validate_foreign_key(:protected_branch_merge_access_levels, :user_id, name: fk_name)
+ end
+end
diff --git a/db/migrate/20200408154349_validate_protected_branch_merge_access_levels_user_id_foreign_key.rb b/db/migrate/20200408154349_validate_protected_branch_merge_access_levels_user_id_foreign_key.rb
new file mode 100644
index 00000000000..c4ec957d607
--- /dev/null
+++ b/db/migrate/20200408154349_validate_protected_branch_merge_access_levels_user_id_foreign_key.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class ValidateProtectedBranchMergeAccessLevelsUserIdForeignKey < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ CONSTRAINT_NAME = 'fk_protected_branch_merge_access_levels_user_id'
+
+ def up
+ validate_foreign_key :protected_branch_merge_access_levels, :user_id, name: CONSTRAINT_NAME
+ end
+
+ def down
+ # no op
+ end
+end
diff --git a/db/migrate/20200408154411_add_path_locks_user_id_foreign_key.rb b/db/migrate/20200408154411_add_path_locks_user_id_foreign_key.rb
new file mode 100644
index 00000000000..5cab846d281
--- /dev/null
+++ b/db/migrate/20200408154411_add_path_locks_user_id_foreign_key.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+# rubocop: disable Migration/AddConcurrentForeignKey
+# rubocop: disable Migration/WithLockRetriesWithoutDdlTransaction
+class AddPathLocksUserIdForeignKey < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ CONSTRAINT_NAME = 'fk_path_locks_user_id'
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_foreign_key(:path_locks, :users, on_delete: :cascade, validate: false, name: CONSTRAINT_NAME)
+ remove_foreign_key_if_exists(:path_locks, column: :user_id, on_delete: nil)
+ end
+ end
+
+ def down
+ fk_exists = foreign_key_exists?(:path_locks, :users, column: :user_id, on_delete: nil)
+
+ unless fk_exists
+ with_lock_retries do
+ add_foreign_key(:path_locks, :users, column: :user_id, validate: false)
+ end
+ end
+
+ remove_foreign_key_if_exists(:path_locks, column: :user_id, name: CONSTRAINT_NAME)
+
+ fk_name = concurrent_foreign_key_name(:path_locks, :user_id, prefix: 'fk_rails_')
+ validate_foreign_key(:path_locks, :user_id, name: fk_name)
+ end
+end
diff --git a/db/migrate/20200408154428_validate_path_locks_user_id_foreign_key.rb b/db/migrate/20200408154428_validate_path_locks_user_id_foreign_key.rb
new file mode 100644
index 00000000000..500409ee44a
--- /dev/null
+++ b/db/migrate/20200408154428_validate_path_locks_user_id_foreign_key.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class ValidatePathLocksUserIdForeignKey < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ CONSTRAINT_NAME = 'fk_path_locks_user_id'
+
+ def up
+ validate_foreign_key :path_locks, :user_id, name: CONSTRAINT_NAME
+ end
+
+ def down
+ # no op
+ end
+end
diff --git a/db/migrate/20200408154455_add_protected_branch_push_access_levels_user_id_foreign_key.rb b/db/migrate/20200408154455_add_protected_branch_push_access_levels_user_id_foreign_key.rb
new file mode 100644
index 00000000000..c0c844b8853
--- /dev/null
+++ b/db/migrate/20200408154455_add_protected_branch_push_access_levels_user_id_foreign_key.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+# rubocop: disable Migration/AddConcurrentForeignKey
+# rubocop: disable Migration/WithLockRetriesWithoutDdlTransaction
+class AddProtectedBranchPushAccessLevelsUserIdForeignKey < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ CONSTRAINT_NAME = 'fk_protected_branch_push_access_levels_user_id'
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_foreign_key(:protected_branch_push_access_levels, :users, on_delete: :cascade, validate: false, name: CONSTRAINT_NAME)
+ remove_foreign_key_if_exists(:protected_branch_push_access_levels, column: :user_id, on_delete: nil)
+ end
+ end
+
+ def down
+ fk_exists = foreign_key_exists?(:protected_branch_push_access_levels, :users, column: :user_id, on_delete: nil)
+
+ unless fk_exists
+ with_lock_retries do
+ add_foreign_key(:protected_branch_push_access_levels, :users, column: :user_id, validate: false)
+ end
+ end
+
+ remove_foreign_key_if_exists(:protected_branch_push_access_levels, column: :user_id, name: CONSTRAINT_NAME)
+
+ fk_name = concurrent_foreign_key_name(:protected_branch_push_access_levels, :user_id, prefix: 'fk_rails_')
+ validate_foreign_key(:protected_branch_push_access_levels, :user_id, name: fk_name)
+ end
+end
diff --git a/db/migrate/20200408154533_validate_protected_branch_push_access_levels_user_id_foreign_key.rb b/db/migrate/20200408154533_validate_protected_branch_push_access_levels_user_id_foreign_key.rb
new file mode 100644
index 00000000000..d6f9cab6d7e
--- /dev/null
+++ b/db/migrate/20200408154533_validate_protected_branch_push_access_levels_user_id_foreign_key.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+class ValidateProtectedBranchPushAccessLevelsUserIdForeignKey < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ CONSTRAINT_NAME = 'fk_protected_branch_push_access_levels_user_id'
+
+ def up
+ validate_foreign_key :protected_branch_push_access_levels, :user_id, name: CONSTRAINT_NAME
+ end
+
+ def down
+ # no op
+ end
+end
diff --git a/db/migrate/20200408154604_add_u2f_registrations_user_id_foreign_key.rb b/db/migrate/20200408154604_add_u2f_registrations_user_id_foreign_key.rb
new file mode 100644
index 00000000000..0dc8a967955
--- /dev/null
+++ b/db/migrate/20200408154604_add_u2f_registrations_user_id_foreign_key.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+# rubocop: disable Migration/AddConcurrentForeignKey
+# rubocop: disable Migration/WithLockRetriesWithoutDdlTransaction
+class AddU2fRegistrationsUserIdForeignKey < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ CONSTRAINT_NAME = 'fk_u2f_registrations_user_id'
+
+ disable_ddl_transaction!
+
+ def up
+ with_lock_retries do
+ add_foreign_key(:u2f_registrations, :users, on_delete: :cascade, validate: false, name: CONSTRAINT_NAME)
+ remove_foreign_key_if_exists(:u2f_registrations, column: :user_id, on_delete: nil)
+ end
+ end
+
+ def down
+ fk_exists = foreign_key_exists?(:u2f_registrations, :users, column: :user_id, on_delete: nil)
+
+ unless fk_exists
+ with_lock_retries do
+ add_foreign_key(:u2f_registrations, :users, column: :user_id, validate: false)
+ end
+ end
+
+ remove_foreign_key_if_exists(:u2f_registrations, column: :user_id, name: CONSTRAINT_NAME)
+
+ fk_name = concurrent_foreign_key_name(:u2f_registrations, :user_id, prefix: 'fk_rails_')
+ validate_foreign_key(:u2f_registrations, :user_id, name: fk_name)
+ end
+end
diff --git a/db/migrate/20200408154624_validate_u2f_registrations_user_id_foreign_key.rb b/db/migrate/20200408154624_validate_u2f_registrations_user_id_foreign_key.rb
new file mode 100644
index 00000000000..ff723a4793f
--- /dev/null
+++ b/db/migrate/20200408154624_validate_u2f_registrations_user_id_foreign_key.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+#
+class ValidateU2fRegistrationsUserIdForeignKey < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ CONSTRAINT_NAME = 'fk_u2f_registrations_user_id'
+
+ def up
+ validate_foreign_key :u2f_registrations, :user_id, name: CONSTRAINT_NAME
+ end
+
+ def down
+ # no op
+ end
+end
diff --git a/db/migrate/20200408212219_add_status_page_url_to_status_page_settings.rb b/db/migrate/20200408212219_add_status_page_url_to_status_page_settings.rb
new file mode 100644
index 00000000000..3b3849c109c
--- /dev/null
+++ b/db/migrate/20200408212219_add_status_page_url_to_status_page_settings.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddStatusPageUrlToStatusPageSettings < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column :status_page_settings, :status_page_url, :text
+ add_text_limit :status_page_settings, :status_page_url, 1024
+ end
+
+ def down
+ remove_column :status_page_settings, :status_page_url
+ end
+end
diff --git a/db/migrate/20200409085956_add_partial_index_on_import_failures_retry_count.rb b/db/migrate/20200409085956_add_partial_index_on_import_failures_retry_count.rb
new file mode 100644
index 00000000000..0999f7b4c95
--- /dev/null
+++ b/db/migrate/20200409085956_add_partial_index_on_import_failures_retry_count.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddPartialIndexOnImportFailuresRetryCount < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :import_failures, [:project_id, :correlation_id_value], where: 'retry_count = 0'
+ end
+
+ def down
+ remove_concurrent_index :import_failures, [:project_id, :correlation_id_value]
+ end
+end
diff --git a/db/migrate/20200410232012_add_metrics_dashboard_access_level_to_project_feature.rb b/db/migrate/20200410232012_add_metrics_dashboard_access_level_to_project_feature.rb
new file mode 100644
index 00000000000..2953cdf3429
--- /dev/null
+++ b/db/migrate/20200410232012_add_metrics_dashboard_access_level_to_project_feature.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddMetricsDashboardAccessLevelToProjectFeature < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_column :project_features, :metrics_dashboard_access_level, :integer
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_column :project_features, :metrics_dashboard_access_level, :integer
+ end
+ end
+end
diff --git a/db/migrate/20200413072059_add_group_owners_can_manage_default_branch_protection_to_application_settings.rb b/db/migrate/20200413072059_add_group_owners_can_manage_default_branch_protection_to_application_settings.rb
new file mode 100644
index 00000000000..eea564d00f4
--- /dev/null
+++ b/db/migrate/20200413072059_add_group_owners_can_manage_default_branch_protection_to_application_settings.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddGroupOwnersCanManageDefaultBranchProtectionToApplicationSettings < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default(:application_settings,
+ :group_owners_can_manage_default_branch_protection,
+ :boolean,
+ default: true)
+ end
+
+ def down
+ remove_column :application_settings, :group_owners_can_manage_default_branch_protection
+ end
+end
diff --git a/db/migrate/20200414144547_remove_index_projects_on_creator_id_and_created_at_from_projects.rb b/db/migrate/20200414144547_remove_index_projects_on_creator_id_and_created_at_from_projects.rb
new file mode 100644
index 00000000000..c4409fcc55d
--- /dev/null
+++ b/db/migrate/20200414144547_remove_index_projects_on_creator_id_and_created_at_from_projects.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class RemoveIndexProjectsOnCreatorIdAndCreatedAtFromProjects < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'index_projects_on_creator_id_and_created_at'
+
+ disable_ddl_transaction!
+
+ def up
+ remove_concurrent_index_by_name :projects, INDEX_NAME
+ end
+
+ def down
+ add_concurrent_index :projects, [:creator_id, :created_at], name: INDEX_NAME
+ end
+end
diff --git a/db/migrate/20200415160722_remove_not_null_lfs_objects_constraint.rb b/db/migrate/20200415160722_remove_not_null_lfs_objects_constraint.rb
new file mode 100644
index 00000000000..58cfa8e8969
--- /dev/null
+++ b/db/migrate/20200415160722_remove_not_null_lfs_objects_constraint.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class RemoveNotNullLfsObjectsConstraint < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ execute <<~SQL
+ ALTER TABLE lfs_objects DROP CONSTRAINT IF EXISTS lfs_objects_file_store_not_null;
+ SQL
+ end
+ end
+
+ def down
+ # No-op
+ end
+end
diff --git a/db/migrate/20200415161021_remove_not_null_ci_job_artifacts_constraint.rb b/db/migrate/20200415161021_remove_not_null_ci_job_artifacts_constraint.rb
new file mode 100644
index 00000000000..65430c180ce
--- /dev/null
+++ b/db/migrate/20200415161021_remove_not_null_ci_job_artifacts_constraint.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class RemoveNotNullCiJobArtifactsConstraint < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ execute <<~SQL
+ ALTER TABLE ci_job_artifacts DROP CONSTRAINT IF EXISTS ci_job_artifacts_file_store_not_null;
+ SQL
+ end
+ end
+
+ def down
+ # No-op
+ end
+end
diff --git a/db/migrate/20200415161206_remove_not_null_uploads_constraint.rb b/db/migrate/20200415161206_remove_not_null_uploads_constraint.rb
new file mode 100644
index 00000000000..23f202bac7e
--- /dev/null
+++ b/db/migrate/20200415161206_remove_not_null_uploads_constraint.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class RemoveNotNullUploadsConstraint < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ execute <<~SQL
+ ALTER TABLE uploads DROP CONSTRAINT IF EXISTS uploads_store_not_null;
+ SQL
+ end
+ end
+
+ def down
+ # No-op
+ end
+end
diff --git a/db/migrate/20200415192656_add_name_regex_keep_to_container_expiration_policies.rb b/db/migrate/20200415192656_add_name_regex_keep_to_container_expiration_policies.rb
new file mode 100644
index 00000000000..e223d94caf7
--- /dev/null
+++ b/db/migrate/20200415192656_add_name_regex_keep_to_container_expiration_policies.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class AddNameRegexKeepToContainerExpirationPolicies < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ CONSTRAINT_NAME = 'container_expiration_policies_name_regex_keep'
+
+ def up
+ add_column(:container_expiration_policies, :name_regex_keep, :text)
+ add_text_limit(:container_expiration_policies, :name_regex_keep, 255, constraint_name: CONSTRAINT_NAME)
+ end
+
+ def down
+ remove_check_constraint(:container_expiration_policies, CONSTRAINT_NAME)
+ remove_column(:container_expiration_policies, :name_regex_keep)
+ end
+end
diff --git a/db/migrate/20200416120128_add_columns_to_terraform_state.rb b/db/migrate/20200416120128_add_columns_to_terraform_state.rb
new file mode 100644
index 00000000000..e657b1fde3f
--- /dev/null
+++ b/db/migrate/20200416120128_add_columns_to_terraform_state.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class AddColumnsToTerraformState < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ add_column :terraform_states, :lock_xid, :string, limit: 255
+ add_column :terraform_states, :locked_at, :datetime_with_timezone
+ add_column :terraform_states, :locked_by_user_id, :bigint
+ add_column :terraform_states, :uuid, :string, limit: 32, null: false # rubocop:disable Rails/NotNullColumn (table not used yet)
+ add_column :terraform_states, :name, :string, limit: 255
+ add_index :terraform_states, :locked_by_user_id # rubocop:disable Migration/AddIndex (table not used yet)
+ add_index :terraform_states, :uuid, unique: true # rubocop:disable Migration/AddIndex (table not used yet)
+ add_index :terraform_states, [:project_id, :name], unique: true # rubocop:disable Migration/AddIndex (table not used yet)
+ remove_index :terraform_states, :project_id # rubocop:disable Migration/RemoveIndex (table not used yet)
+ end
+end
diff --git a/db/migrate/20200416120354_add_locked_by_user_id_foreign_key_to_terraform_state.rb b/db/migrate/20200416120354_add_locked_by_user_id_foreign_key_to_terraform_state.rb
new file mode 100644
index 00000000000..ecee028351a
--- /dev/null
+++ b/db/migrate/20200416120354_add_locked_by_user_id_foreign_key_to_terraform_state.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddLockedByUserIdForeignKeyToTerraformState < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ def up
+ with_lock_retries do
+ add_foreign_key :terraform_states, :users, column: :locked_by_user_id # rubocop:disable Migration/AddConcurrentForeignKey
+ end
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key :terraform_states, column: :locked_by_user_id
+ end
+ end
+end