From 5b23c35bd360a4a5454a97ca47b59f4571e5c58d Mon Sep 17 00:00:00 2001 From: Tim Lewis Date: Tue, 3 Oct 2023 16:29:53 -0400 Subject: [PATCH] Added `SET FOREIGN_KEY_CHECKS` SQL to wipe_everyting script (prevents issues with FK checks during DELETE), added default Community creation, adjusted command (removed `bundle exec`) --- Gemfile.lock | 3 +++ scripts/wipe_everything.rb | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9dc517521..4d7339c45 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -386,6 +388,7 @@ GEM zeitwerk (2.6.11) PLATFORMS + x86_64-darwin-21 x86_64-linux DEPENDENCIES diff --git a/scripts/wipe_everything.rb b/scripts/wipe_everything.rb index f9cdb1127..b5311f9a1 100644 --- a/scripts/wipe_everything.rb +++ b/scripts/wipe_everything.rb @@ -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`