Skip to content

Instantly share code, notes, and snippets.

@nownabe
Created November 4, 2022 07:43
Show Gist options
  • Save nownabe/e63958ca42f11f871f2506be3a5802ba to your computer and use it in GitHub Desktop.
Save nownabe/e63958ca42f11f871f2506be3a5802ba to your computer and use it in GitHub Desktop.
DatabaseCleaner for Spanner
class MyDeletionStrategy < DatabaseCleaner::ActiveRecord::Deletion
def delete_tables(connection, table_names)
# TODO
end
def delete_table(connection, table_name)
connection.execute("DELETE FROM #{connection.quote_table_name(table_name)} WHERE true")
end
end
DatabaseCleaner.strategy = MyDeletionStrategy.new
# https://github.com/DatabaseCleaner/database_cleaner-active_record/blob/main/lib/database_cleaner/active_record/deletion.rb#L25-L27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment