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();"
|
|
|
|
|
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
|