Move migration_table_name to ActiveRecord::Base

This commit is contained in:
Ernesto Tagwerker 2017-05-02 15:37:43 -04:00
parent d95d522fa4
commit 1f40782952
3 changed files with 11 additions and 11 deletions

View file

@ -57,6 +57,14 @@ module DatabaseCleaner
end end
end end
def self.migration_table_name
if ::ActiveRecord::VERSION::MAJOR < 5
::ActiveRecord::Migrator.schema_migrations_table_name
else
::ActiveRecord::SchemaMigration.table_name
end
end
private private
def lookup_from_connection_pool def lookup_from_connection_pool

View file

@ -72,7 +72,7 @@ module DatabaseCleaner::ActiveRecord
INFORMATION_SCHEMA.TABLES INFORMATION_SCHEMA.TABLES
WHERE WHERE
table_schema = '#{db_name}' table_schema = '#{db_name}'
AND table_name <> 'schema_migrations'; AND table_name <> '#{migration_table_name}';
SQL SQL
end end
end end

View file

@ -192,7 +192,7 @@ module DatabaseCleaner
FROM pg_tables FROM pg_tables
WHERE WHERE
tablename !~ '_prt_' AND tablename !~ '_prt_' AND
tablename <> '#{migration_table_name}' AND tablename <> '#{::DatabaseCleaner::ActiveRecord::Base.migration_table_name}' AND
schemaname = ANY (current_schemas(false)) schemaname = ANY (current_schemas(false))
_SQL _SQL
rows.collect { |result| result.first } rows.collect { |result| result.first }
@ -257,15 +257,7 @@ module DatabaseCleaner::ActiveRecord
# overwritten # overwritten
def migration_storage_names def migration_storage_names
[migration_table_name] [::DatabaseCleaner::ActiveRecord::Base.migration_table_name]
end
def migration_table_name
if ActiveRecord::VERSION::MAJOR < 5
::ActiveRecord::Migrator.schema_migrations_table_name
else
::ActiveRecord::SchemaMigration.table_name
end
end end
def cache_tables? def cache_tables?