diff --git a/api/run-db_init-dev.sh b/api/run-db_init-dev.sh new file mode 100755 index 000000000..576613d6f --- /dev/null +++ b/api/run-db_init-dev.sh @@ -0,0 +1,12 @@ +#!/bin/zsh +set -a +. .env +pg_dbname='release_test' +init_script='../scripts/schema/db/init_dbs/postgresql/init_schema.sql' + +PGPASSWORD=$pg_password +psql -h $pg_host -p $pg_port -U $pg_user -v ON_ERROR_STOP=1 -c "CREATE DATABASE $pg_dbname;" +sleep 1s +psql -h $pg_host -p $pg_port -U $pg_user -d $pg_dbname -v ON_ERROR_STOP=1 -f $init_script +sleep 1s +psql -h $pg_host -p $pg_port -U $pg_user -v ON_ERROR_STOP=1 -c "DROP DATABASE $pg_dbname;" \ No newline at end of file diff --git a/ee/api/.gitignore b/ee/api/.gitignore index 15be40a0e..04c6392f3 100644 --- a/ee/api/.gitignore +++ b/ee/api/.gitignore @@ -278,3 +278,4 @@ Pipfile.lock /routers/subs/health.py /chalicelib/core/spot.py /chalicelib/core/unprocessed_sessions.py +/run-db_init-dev.sh diff --git a/ee/api/clean-dev.sh b/ee/api/clean-dev.sh index 261ffbbc5..7d219d610 100755 --- a/ee/api/clean-dev.sh +++ b/ee/api/clean-dev.sh @@ -87,6 +87,7 @@ rm -rf ./routers/subs/__init__.py rm -rf ./routers/subs/v1_api.py rm -rf ./run-alerts-dev.sh rm -rf ./run-dev.sh +rm -rf ./run-db_init-dev.sh rm -rf ./schemas/overrides.py rm -rf ./schemas/schemas.py rm -rf ./schemas/transformers_validators.py diff --git a/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql b/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql index 3fb78f6c2..66bf91793 100644 --- a/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql +++ b/ee/scripts/schema/db/init_dbs/postgresql/init_schema.sql @@ -17,6 +17,7 @@ BEGIN; CREATE SCHEMA IF NOT EXISTS events_common; CREATE SCHEMA IF NOT EXISTS events; CREATE SCHEMA IF NOT EXISTS events_ios; +CREATE SCHEMA IF NOT EXISTS or_cache; CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE EXTENSION IF NOT EXISTS pgcrypto; @@ -1317,4 +1318,5 @@ CREATE TABLE or_cache.autocomplete_top_values UNIQUE NULLS NOT DISTINCT (project_id, event_type, event_key) ); + COMMIT; \ No newline at end of file