Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wipe_everything.rb Script to handle FK Checks #1211

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`
Loading