-
Notifications
You must be signed in to change notification settings - Fork 2
/
migrate_db.sh
executable file
·34 lines (26 loc) · 1002 Bytes
/
migrate_db.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
# Populate porick's database with data from an existing Chirpy! installation
# Insert the MySQL password for porick here
PWD=''
# Insert the Chirpy! database name here
CHIRPYDB='chirpy'
mysqldump -u root -p $CHIRPYDB --tables chirpy_tags chirpy_quote_tag chirpy_quotes > tmp_dump.sql
cat <<EOF | mysql -u root -p
CREATE DATABASE IF NOT EXISTS porick;
GRANT ALL PRIVILEGES ON porick.* TO 'porick'@'localhost' IDENTIFIED BY '$PWD';
FLUSH PRIVILEGES;
EOF
mysql -u root -p porick < tmp_dump.sql
rm -f tmp_dump.sql
cat <<EOF | mysql -u root -p porick
RENAME TABLE chirpy_tags TO tags;
RENAME TABLE chirpy_quotes TO quotes;
RENAME TABLE chirpy_quote_tag to quote_to_tag;
ALTER TABLE quotes ADD COLUMN status tinyint(1) NOT NULL DEFAULT 0;
UPDATE quotes SET status=0 WHERE approved=0;
UPDATE quotes SET status=1 WHERE approved=1;
UPDATE quotes SET status=3 WHERE flagged=1;
ALTER TABLE quotes DROP COLUMN flagged;
ALTER TABLE quotes DROP COLUMN approved;
EOF
paster setup-app production.ini