diff options
Diffstat (limited to 'db')
8 files changed, 55 insertions, 6 deletions
diff --git a/db/migrate/20200215222507_drop_forked_project_links_fk.rb b/db/migrate/20200215222507_drop_forked_project_links_fk.rb index 0be7a57ed0e..226e3fbcf85 100644 --- a/db/migrate/20200215222507_drop_forked_project_links_fk.rb +++ b/db/migrate/20200215222507_drop_forked_project_links_fk.rb @@ -19,7 +19,6 @@ class DropForkedProjectLinksFk < ActiveRecord::Migration[6.0] unless foreign_key_exists?(:forked_project_links, :projects, column: :forked_to_project_id) # rubocop: disable Migration/WithLockRetriesWithoutDdlTransaction with_lock_retries do - # rubocop: disable Migration/AddConcurrentForeignKey add_foreign_key :forked_project_links, :projects, column: :forked_to_project_id, on_delete: :cascade, validate: false end # rubocop: enable Migration/WithLockRetriesWithoutDdlTransaction 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 index 69222710026..3d41707face 100644 --- 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 @@ -1,6 +1,5 @@ # frozen_string_literal: true -# rubocop: disable Migration/AddConcurrentForeignKey # rubocop: disable Migration/WithLockRetriesWithoutDdlTransaction class AddProtectedTagCreateAccessLevelsUserIdForeignKey < ActiveRecord::Migration[6.0] include Gitlab::Database::MigrationHelpers 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 index 1b31da93fe7..943aea902fa 100644 --- 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 @@ -1,6 +1,5 @@ # frozen_string_literal: true -# rubocop: disable Migration/AddConcurrentForeignKey # rubocop: disable Migration/WithLockRetriesWithoutDdlTransaction class AddProtectedBranchMergeAccessLevelsUserIdForeignKey < ActiveRecord::Migration[6.0] include Gitlab::Database::MigrationHelpers 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 index 5cab846d281..65e857ff88f 100644 --- a/db/migrate/20200408154411_add_path_locks_user_id_foreign_key.rb +++ b/db/migrate/20200408154411_add_path_locks_user_id_foreign_key.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# rubocop: disable Migration/AddConcurrentForeignKey # rubocop: disable Migration/WithLockRetriesWithoutDdlTransaction class AddPathLocksUserIdForeignKey < ActiveRecord::Migration[6.0] include Gitlab::Database::MigrationHelpers 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 index c0c844b8853..01676156fb5 100644 --- 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 @@ -1,6 +1,5 @@ # frozen_string_literal: true -# rubocop: disable Migration/AddConcurrentForeignKey # rubocop: disable Migration/WithLockRetriesWithoutDdlTransaction class AddProtectedBranchPushAccessLevelsUserIdForeignKey < ActiveRecord::Migration[6.0] include Gitlab::Database::MigrationHelpers 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 index 0dc8a967955..74d826adc88 100644 --- a/db/migrate/20200408154604_add_u2f_registrations_user_id_foreign_key.rb +++ b/db/migrate/20200408154604_add_u2f_registrations_user_id_foreign_key.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# rubocop: disable Migration/AddConcurrentForeignKey # rubocop: disable Migration/WithLockRetriesWithoutDdlTransaction class AddU2fRegistrationsUserIdForeignKey < ActiveRecord::Migration[6.0] include Gitlab::Database::MigrationHelpers diff --git a/db/post_migrate/20200312134637_backfill_environment_id_on_deployment_merge_requests.rb b/db/post_migrate/20200312134637_backfill_environment_id_on_deployment_merge_requests.rb new file mode 100644 index 00000000000..24b652a3299 --- /dev/null +++ b/db/post_migrate/20200312134637_backfill_environment_id_on_deployment_merge_requests.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +class BackfillEnvironmentIdOnDeploymentMergeRequests < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + BATCH_SIZE = 400 + DELAY = 1.minute + + disable_ddl_transaction! + + def up + max_mr_id = DeploymentMergeRequest + .select(:merge_request_id) + .distinct + .order(merge_request_id: :desc) + .limit(1) + .pluck(:merge_request_id) + .first || 0 + + last_mr_id = 0 + step = 0 + + while last_mr_id < max_mr_id + stop = + DeploymentMergeRequest + .select(:merge_request_id) + .distinct + .where('merge_request_id > ?', last_mr_id) + .order(:merge_request_id) + .offset(BATCH_SIZE) + .limit(1) + .pluck(:merge_request_id) + .first + + stop ||= max_mr_id + + migrate_in( + step * DELAY, + 'BackfillEnvironmentIdDeploymentMergeRequests', + [last_mr_id + 1, stop] + ) + + last_mr_id = stop + step += 1 + end + end + + def down + # no-op + + # this migration is designed to delete duplicated data + end +end diff --git a/db/structure.sql b/db/structure.sql index 155f8b9ffb1..6eb86c18d51 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -13419,6 +13419,7 @@ COPY "schema_migrations" (version) FROM STDIN; 20200311214912 20200312053852 20200312125121 +20200312134637 20200312160532 20200312163407 20200313101649 |