From c4edcd7a675c2f8815ad1cd994fea0aeba5eaed3 Mon Sep 17 00:00:00 2001 From: Tuan Nguyen Date: Sat, 11 Jan 2025 10:48:14 -0500 Subject: [PATCH] disable constraints when dropping tables --- bin/import_db.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/import_db.sh b/bin/import_db.sh index ab4af04..32342e0 100755 --- a/bin/import_db.sh +++ b/bin/import_db.sh @@ -1,7 +1,9 @@ #!/bin/bash dump=$1 -echo 'show tables;' | rails db -p | grep -v "Tables_in_" | xargs -i -n 1 echo "DROP TABLE IF EXISTS \`{}\`;" > drop.sql +echo 'SET foreign_key_checks = 0;' > drop.sql + +echo 'show tables;' | rails db -p | grep -v "Tables_in_" | xargs -i -n 1 echo "DROP TABLE IF EXISTS \`{}\`;" >> drop.sql cat drop.sql | rails db -p