Commit 8c6b5b67 authored by Baodong's avatar Baodong

Refactor DEFAULT_SCHEMA_MIGRATIONS_PATH

Use class_attribute instead,
to facilitate the modification of the default value.
parent 4b780458
......@@ -6,7 +6,7 @@ module Gitlab
class Context
attr_reader :connection
DEFAULT_SCHEMA_MIGRATIONS_PATH = "db/schema_migrations"
class_attribute :default_schema_migrations_path, default: 'db/schema_migrations'
def initialize(connection)
@connection = connection
......@@ -30,7 +30,7 @@ module Gitlab
end
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
......
......@@ -10,7 +10,7 @@ RSpec.describe Gitlab::Database::SchemaMigrations::Context do
describe '#schema_directory' 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
context 'CI database' do
......@@ -19,7 +19,7 @@ RSpec.describe Gitlab::Database::SchemaMigrations::Context do
it 'returns a directory path that is database specific' do
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
......
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