Commit 3bdf92cb authored by dfrazao-gitlab's avatar dfrazao-gitlab

Fix spec to properly support many databases

- Add support for multiple databases (CI/Main database)

Related to https://gitlab.com/gitlab-org/gitlab/-/issues/336901

Changelog: added
parent 9b7baf1f
......@@ -2,7 +2,7 @@
module MigrationsHelpers
def active_record_base
ActiveRecord::Base
Gitlab::Database.database_base_models.fetch(self.class.metadata[:database] || :main)
end
def table(name)
......@@ -34,7 +34,7 @@ module MigrationsHelpers
end
def migrations_paths
ActiveRecord::Migrator.migrations_paths
active_record_base.connection.migrations_paths
end
def migration_context
......@@ -52,7 +52,7 @@ module MigrationsHelpers
end
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
key.options[:column].to_s == column.to_s
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