Commit 04df8fe32a5e8d7111efb839a60742a0504fc848
Committed by
Paulo Meireles
1 parent
61945fc5
Exists in
master
and in
29 other branches
[Mezuro] Changed script for kalibro database.
Showing
2 changed files
with
16 additions
and
6 deletions
Show diff stats
plugins/mezuro/script/kalibro_scripts.conf
plugins/mezuro/script/prepare_kalibro_query_file.sh
... | ... | @@ -2,8 +2,16 @@ |
2 | 2 | |
3 | 3 | source plugins/mezuro/script/kalibro_scripts.conf |
4 | 4 | |
5 | -sudo su postgres -c "export PGPASSWORD=$PASSWORD && | |
6 | - if [ -f $QUERYFILE ] | |
7 | - then rm $QUERYFILE | |
8 | - fi && | |
9 | - psql -q -t -d $DATABASE -c \"SELECT 'DELETE FROM ' || n.nspname || '.' || c.relname || ' CASCADE;' FROM pg_catalog.pg_class AS c LEFT JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace WHERE relkind = 'r' AND n.nspname NOT IN ('pg_catalog', 'pg_toast') AND pg_catalog.pg_table_is_visible(c.oid)\" | sed '/$EXCEPTION/d' | sort > $QUERYFILE" | |
5 | +DROPLIMIT="END OF DROP TABLES" | |
6 | +RANGE=$(grep -n "$DROPLIMIT" $PSQLFILE | cut -d":" -f1) | |
7 | +START=1 | |
8 | +END=$(($RANGE - 1)) | |
9 | +CUT=$START,$END\!d | |
10 | +REPLACE="s/DROP TABLE IF EXISTS sequences,/TRUNCATE/" | |
11 | + | |
12 | +if [ -f $QUERYFILE ] | |
13 | + then sudo rm $QUERYFILE | |
14 | +fi | |
15 | + | |
16 | +sed -e "$CUT" -e "$REPLACE" $PSQLFILE > $QUERYFILE | |
17 | +sudo chown postgres.postgres $QUERYFILE | ... | ... |