Commit a2c8fbb6 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch '336901-fix-spec-migrationhelpers-to-properly-support-many-databases' into 'master'

Resolve "Fix spec \`MigrationHelpers\` to properly support many databases" \[RUN AS-IF-FOSS\]

See merge request gitlab-org/gitlab!70063
parents fcd31f67 3bdf92cb
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module MigrationsHelpers module MigrationsHelpers
def active_record_base def active_record_base
ActiveRecord::Base Gitlab::Database.database_base_models.fetch(self.class.metadata[:database] || :main)
end end
def table(name) def table(name)
...@@ -34,7 +34,7 @@ module MigrationsHelpers ...@@ -34,7 +34,7 @@ module MigrationsHelpers
end end
def migrations_paths def migrations_paths
ActiveRecord::Migrator.migrations_paths active_record_base.connection.migrations_paths
end end
def migration_context def migration_context
...@@ -52,7 +52,7 @@ module MigrationsHelpers ...@@ -52,7 +52,7 @@ module MigrationsHelpers
end end
def foreign_key_exists?(source, target = nil, column: nil) def foreign_key_exists?(source, target = nil, column: nil)
ActiveRecord::Base.connection.foreign_keys(source).any? do |key| active_record_base.connection.foreign_keys(source).any? do |key|
if column if column
key.options[:column].to_s == column.to_s key.options[:column].to_s == column.to_s
else else
......
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