Skip to content

Commit ac4ac33

Browse files
committed
Harden Seeds#flushdb
1 parent e39f8ae commit ac4ac33

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

app/lib/seeds.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ def perform
2020
def flushdb
2121
raise 'Not in production!' if production?
2222

23-
load_all_models!
24-
25-
ActiveRecord::Base.connection.transaction do
26-
ApplicationRecord.descendants.each(&:delete_all)
23+
ActiveRecord::Base.connection.tables.each do |table|
24+
next if table == 'schema_migrations'
25+
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table} CASCADE;")
2726
end
2827
end
2928

0 commit comments

Comments
 (0)