Commit bb05a727 authored by Dylan Griffith's avatar Dylan Griffith

Make db:migrate:reset work with GITLAB_USE_MODEL_LOAD_BALANCING=true

The problem was caused by using the the ActsAsTaggableOn::Tagging model
directly which has some weird configuration in
https://gitlab.com/gitlab-org/gitlab/-/blob/9c2682cf013dae1d469e6c2c6fea3f6d1aa0fa5a/config/initializers/1_acts_as_taggable.rb#L15
which forces the connection to use the CI connection. But this doesn't
make sense in the migration context where we are migrating the schema
for the `main` database. As such we need to just define a model in the
migration like we would normally do then it will use the correct
connection for the current migration.
parent 5606ac4c
...@@ -377,8 +377,6 @@ db:migrate:reset decomposed: ...@@ -377,8 +377,6 @@ db:migrate:reset decomposed:
- db:migrate:reset - db:migrate:reset
- .decomposed-database - .decomposed-database
- .rails:rules:decomposed-databases - .rails:rules:decomposed-databases
variables:
GITLAB_USE_MODEL_LOAD_BALANCING: "false"
db:migrate-from-previous-major-version: db:migrate-from-previous-major-version:
extends: .db-job-base extends: .db-job-base
......
...@@ -8,8 +8,12 @@ class DeleteIssueMergeRequestTaggingsRecords < Gitlab::Database::Migration[1.0] ...@@ -8,8 +8,12 @@ class DeleteIssueMergeRequestTaggingsRecords < Gitlab::Database::Migration[1.0]
BATCH_SIZE = 3_000 BATCH_SIZE = 3_000
TAGGABLE_TYPES = %w(Issue MergeRequest) TAGGABLE_TYPES = %w(Issue MergeRequest)
class Tagging < ActiveRecord::Base
self.table_name = "taggings"
end
def up def up
sleep 2 while ActsAsTaggableOn::Tagging.where(taggable_type: TAGGABLE_TYPES).limit(BATCH_SIZE).delete_all > 0 sleep 2 while Tagging.where(taggable_type: TAGGABLE_TYPES).limit(BATCH_SIZE).delete_all > 0
remove_concurrent_index_by_name :taggings, INDEX_NAME remove_concurrent_index_by_name :taggings, INDEX_NAME
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment