Class: DatabaseCleaner::Spanner::Deletion
- Inherits:
-
Strategy
- Object
- Strategy
- DatabaseCleaner::Spanner::Deletion
- Defined in:
- lib/database_cleaner/spanner/deletion.rb
Constant Summary collapse
- SQL =
<<~SQL WITH References AS ( SELECT ccu.TABLE_NAME AS TABLE_NAME , tc.TABLE_NAME AS referenced_by FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS tc INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE AS ccu USING (CONSTRAINT_NAME) WHERE CONSTRAINT_TYPE = "FOREIGN KEY" AND tc.TABLE_NAME <> ccu.TABLE_NAME ) SELECT t.TABLE_NAME AS table_name , children.TABLE_NAME AS child_table_name , children.ON_DELETE_ACTION AS delete_action , r.referenced_by AS referenced_by FROM INFORMATION_SCHEMA.TABLES AS t LEFT JOIN INFORMATION_SCHEMA.TABLES AS children ON t.TABLE_NAME = children.PARENT_TABLE_NAME LEFT JOIN References AS r ON t.TABLE_NAME = r.table_name WHERE t.TABLE_TYPE = "BASE TABLE" SQL
Instance Method Summary collapse
- #clean ⇒ Object
-
#initialize(only: [], except: [], batch_deletion: false, cache_tables: true) ⇒ Deletion
constructor
A new instance of Deletion.
Constructor Details
#initialize(only: [], except: [], batch_deletion: false, cache_tables: true) ⇒ Deletion
Returns a new instance of Deletion.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/database_cleaner/spanner/deletion.rb', line 33 def initialize( only: [], except: [], batch_deletion: false, cache_tables: true ) @only = only @except = except @batch_deletion = batch_deletion @cache_tables = cache_tables @deletable_tables = {} end |
Instance Method Details
#clean ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/database_cleaner/spanner/deletion.rb', line 47 def clean if @batch_deletion clean_as_batch else clean_each end end |