Skip to content

Commit

Permalink
disable constraints when dropping tables
Browse files Browse the repository at this point in the history
  • Loading branch information
amtuannguyen committed Jan 11, 2025
1 parent b5e7e40 commit c4edcd7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bin/import_db.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit c4edcd7

Please sign in to comment.