You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using dataset erased all data from all tables in the test db. In my case, working with a legacy database that only needs to be read from, this is a Bad Thing. This monkey patch at the bottom of spec_helper.rb helps:
module Dataset
module Database # :nodoc:
# Provides Dataset a way to clear, dump and load databases.
class Base
include FileUtils
def clear
connection = ActiveRecord::Base.connection
ActiveRecord::Base.silence do
connection.tables.each do |table_name|
unless %w{table_to_keep another_table even_another_table}.include? (table_name)
puts "Emptying #{table_name}"
connection.delete "DELETE FROM #{connection.quote_table_name(table_name)}",
"Dataset::Database#clear" unless table_name == ActiveRecord::Migrator.schema_migrations_table_name
else
puts "Skipping #{table_name}"
end
end
end
end
end
end
end
It would be great to have a setting in dataset that lets me specify either which tables NOT to empty and/or which tables TO empty.
The text was updated successfully, but these errors were encountered:
Using dataset erased all data from all tables in the test db. In my case, working with a legacy database that only needs to be read from, this is a Bad Thing. This monkey patch at the bottom of spec_helper.rb helps:
It would be great to have a setting in dataset that lets me specify either which tables NOT to empty and/or which tables TO empty.
The text was updated successfully, but these errors were encountered: