2 changed files with 36 additions and 0 deletions
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
DO $$ DECLARE |
||||
r RECORD; |
||||
BEGIN |
||||
-- if the schema you operate on is not "current", you will want to |
||||
-- replace current_schema() in query with 'schematodeletetablesfrom' |
||||
-- *and* update the generate 'DROP...' accordingly. |
||||
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP |
||||
EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE'; |
||||
END LOOP; |
||||
END $$; |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
#! /bin/bash |
||||
|
||||
PYTHON=../venv/bin/python |
||||
MANAGE=../manage.py |
||||
|
||||
dump_help() |
||||
{ |
||||
cat <<EOF |
||||
$0 <postgres_dump> |
||||
|
||||
ecrase la base de donnee de l'application |
||||
avec le dump postgresql custom indiqué |
||||
EOF |
||||
} |
||||
|
||||
[[ "x$1" = "x-h" ]] && { dump_help ; exit ; } |
||||
[[ $# -lt 1 ]] && { dump_help ; exit ; } |
||||
DUMP_FILE="$1" |
||||
read -p "Ecraser la base de donnee avec le contenu de [${DUMP_FILE}] (o/n)" ANS |
||||
[[ "$ANS" = "o" ]] || exit |
||||
|
||||
echo "Suppression de la base de donnée" |
||||
cat psql_reset.sql | $PYTHON $MANAGE dbshell |
||||
|
||||
echo "Restauration de la base depuis le dump" |
||||
pg_restore -xO "$DUMP_FILE" | $PYTHON $MANAGE dbshell |
Loading…
Reference in new issue