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
def self.migration_table_name
if ::ActiveRecord::VERSION::MAJOR < 5
::ActiveRecord::Migrator.schema_migrations_table_name
else
::ActiveRecord::SchemaMigration.table_name
end
end
private
def lookup_from_connection_pool

View file

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

View file

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