fp/scripts/postgres-create.sh

101 lines
3.3 KiB
Bash
Executable File

#!/bin/sh
# bindir=$(dirname "$(readlink -fm "$0")")
# source "${bindir}/../.env"
if [ -z $POSTGRES_REALTIME_PASSWORD ]; then
echo "POSTGRES_REALTIME_PASSWORD was missing in env"
exit 5
fi
## Create the temporal databases
kubectl -n futureporn exec postgres -- psql -U postgres --command "\
CREATE DATABASE temporal_visibility \
WITH \
OWNER = postgres \
ENCODING = 'UTF8' \
LOCALE_PROVIDER = 'libc' \
CONNECTION LIMIT = -1 \
IS_TEMPLATE = False;"
kubectl -n futureporn exec postgres -- psql -U postgres --command "\
CREATE DATABASE temporal \
WITH \
OWNER = postgres \
ENCODING = 'UTF8' \
LOCALE_PROVIDER = 'libc' \
CONNECTION LIMIT = -1 \
IS_TEMPLATE = False;"
# kubectl -n futureporn exec postgres -- psql -U postgres --command "\
# CREATE DATABASE trigger \
# WITH \
# OWNER = postgres \
# ENCODING = 'UTF8' \
# LOCALE_PROVIDER = 'libc' \
# CONNECTION LIMIT = -1 \
# IS_TEMPLATE = False;"
# ./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(TEMPORAL_DB) drop -f
# ./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(TEMPORAL_DB) create
# ./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(TEMPORAL_DB) setup -v 0.0
# ./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(TEMPORAL_DB) update-schema -d ./schema/postgresql/v12/temporal/versioned
# ./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(VISIBILITY_DB) drop -f
# ./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(VISIBILITY_DB) create
# ./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(VISIBILITY_DB) setup-schema -v 0.0
# ./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(VISIBILITY_DB) update-schema -d ./schema/postgresql/v12/visibility/versioned
## Create the futureporn Strapi database
kubectl -n futureporn exec postgres -- psql -U postgres --command "\
CREATE DATABASE futureporn_db \
WITH \
OWNER = postgres \
ENCODING = 'UTF8' \
LOCALE_PROVIDER = 'libc' \
CONNECTION LIMIT = -1 \
IS_TEMPLATE = False;"
## Create the trigger database (for backend tasks)
kubectl -n futureporn exec postgres -- psql -U postgres --command "\
CREATE DATABASE trigger \
WITH \
OWNER = postgres \
ENCODING = 'UTF8' \
LOCALE_PROVIDER = 'libc' \
CONNECTION LIMIT = -1 \
IS_TEMPLATE = False;"
## create futureporn user
kubectl -n futureporn exec postgres -- psql -U postgres --command "\
CREATE ROLE futureporn \
WITH \
LOGIN \
NOSUPERUSER \
NOCREATEDB \
NOCREATEROLE \
INHERIT \
NOREPLICATION \
NOBYPASSRLS \
CONNECTION LIMIT -1 \
PASSWORD '$POSTGRES_REALTIME_PASSWORD';"
## grant futureporn user all privs
kubectl -n futureporn exec postgres -- psql -U postgres --command "\
GRANT ALL PRIVILEGES ON DATABASE trigger TO futureporn;"
## import schema
## I have a file, schema.psql that I want to import. How do I do that?
# kubectl -n futureporn exec postgres -- psql -U postgres --command "\ ;"
# kubectl -n futureporn exec postgres -- psql -U postgres -f - < "${bindir}/postgres-2024-05-09-futureporn_db-schema-only.psql"