-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1fbb051
commit de99b24
Showing
1 changed file
with
3 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
#!/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 | ||
|
||
[ -f "$dump" ] && zcat -f "$dump" | sed '/DROP DATABASE \|CREATE DATABASE \|USE `/d' | sed 's/ datetime / datetime(6) /' > import.sql | ||
[ -f "$dump" ] && zcat -f "$dump" | sed '/^DROP DATABASE \|^CREATE DATABASE \|^USE `/d' | sed 's/ datetime / datetime(6) /' > import.sql | ||
|
||
cat drop.sql | rails db -p | ||
cat import.sql | rails db -p | ||
|
||
rails db:migrate | ||
|
||
rake admin:reindex_all |