mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
Move migration_table_name to ActiveRecord::Base
This commit is contained in:
parent
d95d522fa4
commit
1f40782952
3 changed files with 11 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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?
|
||||
|
|
Loading…
Reference in a new issue