Commit d34f509d authored by Patrick Bair's avatar Patrick Bair

Merge branch 'refactor/default_schema_migrations_path' into 'master'

Refactor DEFAULT_SCHEMA_MIGRATIONS_PATH

See merge request gitlab-org/gitlab!70345
parents 6bf91ae9 8c6b5b67
...@@ -6,7 +6,7 @@ module Gitlab ...@@ -6,7 +6,7 @@ module Gitlab
class Context class Context
attr_reader :connection attr_reader :connection
DEFAULT_SCHEMA_MIGRATIONS_PATH = "db/schema_migrations" class_attribute :default_schema_migrations_path, default: 'db/schema_migrations'
def initialize(connection) def initialize(connection)
@connection = connection @connection = connection
...@@ -30,7 +30,7 @@ module Gitlab ...@@ -30,7 +30,7 @@ module Gitlab
end end
def database_schema_migrations_path def database_schema_migrations_path
@connection.pool.db_config.configuration_hash[:schema_migrations_path] || DEFAULT_SCHEMA_MIGRATIONS_PATH @connection.pool.db_config.configuration_hash[:schema_migrations_path] || self.class.default_schema_migrations_path
end end
end end
end end
......
...@@ -10,7 +10,7 @@ RSpec.describe Gitlab::Database::SchemaMigrations::Context do ...@@ -10,7 +10,7 @@ RSpec.describe Gitlab::Database::SchemaMigrations::Context do
describe '#schema_directory' do describe '#schema_directory' do
it 'returns db/schema_migrations' do it 'returns db/schema_migrations' do
expect(context.schema_directory).to eq(File.join(Rails.root, 'db/schema_migrations')) expect(context.schema_directory).to eq(File.join(Rails.root, described_class.default_schema_migrations_path))
end end
context 'CI database' do context 'CI database' do
...@@ -19,7 +19,7 @@ RSpec.describe Gitlab::Database::SchemaMigrations::Context do ...@@ -19,7 +19,7 @@ RSpec.describe Gitlab::Database::SchemaMigrations::Context do
it 'returns a directory path that is database specific' do it 'returns a directory path that is database specific' do
skip_if_multiple_databases_not_setup skip_if_multiple_databases_not_setup
expect(context.schema_directory).to eq(File.join(Rails.root, 'db/schema_migrations')) expect(context.schema_directory).to eq(File.join(Rails.root, described_class.default_schema_migrations_path))
end end
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