Skip to content

Commit

Permalink
add script to load database from backup
Browse files Browse the repository at this point in the history
  • Loading branch information
amtuannguyen committed Jan 10, 2025
1 parent e9ccc2e commit 7c1c7f5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bin/import_db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
dump=$1

[ -f "$dump" ] && zcat -f "$dump" | grep 'DROP TABLE ' > drop.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

0 comments on commit 7c1c7f5

Please sign in to comment.