Skip to content

Commit

Permalink
Merge pull request #1211 from TimothyDLewis/TimothyDLewis/1195/wipe-e…
Browse files Browse the repository at this point in the history
…verything-script-fails-foreign-key-constraints
  • Loading branch information
ArtOfCode- authored Oct 3, 2023
2 parents 3cbe90f + 329a07a commit d040f8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ GEM
net-smtp (0.3.3)
net-protocol
nio4r (2.5.9)
nokogiri (1.15.3-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.15.3-x86_64-linux)
racc (~> 1.4)
omniauth (2.1.0)
Expand Down Expand Up @@ -386,6 +388,7 @@ GEM
zeitwerk (2.6.11)

PLATFORMS
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
Expand Down
6 changes: 5 additions & 1 deletion scripts/wipe_everything.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ def exec_sql(sql)

conn = ActiveRecord::Base.connection
leave_tables = ['ar_internal_metadata', 'schema_migrations']

exec_sql 'SET FOREIGN_KEY_CHECKS = 0'
(conn.tables - leave_tables).each do |t|
exec_sql "DELETE FROM `#{t}`"
exec_sql "ALTER TABLE `#{t}` AUTO_INCREMENT=1"
end
exec_sql 'SET FOREIGN_KEY_CHECKS = 1'

Community.create(name: 'Dev Community', host: 'localhost:3000')
Rails.cache.clear

`bundle exec rails db:seed`
`rails db:seed`

0 comments on commit d040f8d

Please sign in to comment.