Persist the tsearch_extras extension across rebuilding of the database

We do this by creating a new zulip{_test}_base database that only has the zulip
schema and the tsearch_extras extension.  We then use that as a template when
creating zulip{_test}.

(imported from commit 8adb4b98410e4042a0187902e89c99561eac8c8f)
This commit is contained in:
Zev Benjamin 2014-01-30 17:40:37 -05:00
parent 17826dba42
commit 8767c33536
3 changed files with 21 additions and 5 deletions

View File

@ -1,6 +1,9 @@
#!/bin/sh -xe
echo "DROP SCHEMA zulip CASCADE; CREATE SCHEMA zulip;" | python manage.py dbshell
psql -h localhost postgres zulip <<EOF
DROP DATABASE IF EXISTS zulip;
CREATE DATABASE zulip TEMPLATE zulip_base;
EOF
python manage.py syncdb --noinput
python manage.py migrate

View File

@ -21,7 +21,11 @@ fi
mkdir -p zerver/fixtures
echo "DROP SCHEMA zulip CASCADE; CREATE SCHEMA zulip;" | python manage.py dbshell --settings=zproject.test_settings
psql -h localhost postgres zulip_test <<EOF
DROP DATABASE IF EXISTS zulip_test;
CREATE DATABASE zulip_test TEMPLATE zulip_test_base;
EOF
python manage.py syncdb --noinput --settings=zproject.test_settings
python manage.py migrate --settings=zproject.test_settings --all
migration_status "zerver/fixtures/migration-status"

View File

@ -24,6 +24,7 @@ else
exit
fi
DBNAME_BASE=${DBNAME}_base
$ROOT_POSTGRES $DEFAULT_DB << EOF
CREATE USER $USERNAME WITH PASSWORD '$PASSWORD';
@ -37,13 +38,21 @@ chmod go-rw ~/.pgpass
psql -h localhost postgres $USERNAME <<EOF
DROP DATABASE IF EXISTS $DBNAME;
CREATE DATABASE $DBNAME;
DROP DATABASE IF EXISTS $DBNAME_BASE;
CREATE DATABASE $DBNAME_BASE
EOF
DEFAULT_DB=$DBNAME
psql -h localhost $DBNAME_BASE $USERNAME <<EOF
CREATE SCHEMA zulip;
EOF
$ROOT_POSTGRES $DEFAULT_DB << EOF
$ROOT_POSTGRES $DBNAME_BASE << EOF
DROP SCHEMA public CASCADE;
CREATE EXTENSION tsearch_extras SCHEMA zulip;
EOF
psql -h localhost postgres $USERNAME <<EOF
CREATE DATABASE $DBNAME TEMPLATE $DBNAME_BASE;
EOF
echo "Database created"