2022-10-28 21:52:39 +03:00
#!/usr/bin/env bash
set -euo pipefail
2022-10-25 21:54:36 +03:00
FIXTURES_DIR = " $( dirname " $0 " ) "
2022-12-27 09:56:27 +03:00
echo -e "\n\n\n"
echo "################################################################################################"
2022-11-30 19:57:27 +03:00
echo " Loading Martin test fixtures into ' $PGDATABASE ' as user ' $PGUSER ' "
2022-12-27 09:56:27 +03:00
echo "################################################################################################"
2022-10-25 21:54:36 +03:00
2022-10-28 21:52:39 +03:00
psql -P pager = off -v ON_ERROR_STOP = 1 -c "CREATE EXTENSION IF NOT EXISTS postgis;"
2022-10-31 23:28:21 +03:00
# see https://github.com/postgis/docker-postgis/issues/187
psql -P pager = off -v ON_ERROR_STOP = 1 -c "DROP SCHEMA IF EXISTS tiger CASCADE;"
2022-10-28 21:52:39 +03:00
psql -P pager = off -v ON_ERROR_STOP = 1 -t -c "select version();"
psql -P pager = off -v ON_ERROR_STOP = 1 -t -c "select PostGIS_Full_Version();"
2023-08-04 00:51:10 +03:00
# On error, make sure do delete all the tables we created
# TODO: see if we can have a fail-early service test to detect errors
trap 'echo -e "\n\n\n!!!!!!!!!!!!!!!!!!!!!!!!\n\nDELETING DB $PGDATABASE DUE TO AN ERROR!\n\n\n" && psql -c "DROP SCHEMA IF EXISTS "MixedCase" CASCADE; DROP SCHEMA IF EXISTS autodetect CASCADE;"' ERR
2022-11-30 19:57:27 +03:00
2022-12-27 09:56:27 +03:00
echo -e "\n\n\n"
echo "################################################################################################"
2022-11-30 19:57:27 +03:00
echo " Importing tables from $FIXTURES_DIR /tables "
2022-12-27 09:56:27 +03:00
echo "################################################################################################"
2022-11-30 19:57:27 +03:00
for sql_file in " $FIXTURES_DIR " /tables/*.sql; do
psql -e -P pager = off -v ON_ERROR_STOP = 1 -f " $sql_file "
done
2022-12-27 09:56:27 +03:00
echo -e "\n\n\n"
echo "################################################################################################"
2022-11-30 19:57:27 +03:00
echo " Importing functions from $FIXTURES_DIR /functions "
2022-12-27 09:56:27 +03:00
echo "################################################################################################"
2022-11-30 19:57:27 +03:00
for sql_file in " $FIXTURES_DIR " /functions/*.sql; do
psql -e -P pager = off -v ON_ERROR_STOP = 1 -f " $sql_file "
done
2023-09-30 19:03:23 +03:00
echo -e "\n\n\n"
echo "################################################################################################"
echo "Active pg_hba.conf configuration"
echo "################################################################################################"
2023-09-30 19:38:57 +03:00
psql -P pager = off -v ON_ERROR_STOP = 1 -c "select pg_reload_conf();"
2023-09-30 19:03:23 +03:00
psql -P pager = off -v ON_ERROR_STOP = 1 -c "select * from pg_hba_file_rules;"