diff --git a/api/routers/core.py b/api/routers/core.py index 935eac873..511e60477 100644 --- a/api/routers/core.py +++ b/api/routers/core.py @@ -771,7 +771,7 @@ def signup_handler(data: schemas.UserSignupSchema = Body(...)): return signup.create_step1(data) -@app.post('/projects', tags=['projects']) +@app.put('/projects', tags=['projects']) def create_project(data: schemas.CreateProjectSchema = Body(...), context: schemas.CurrentContext = Depends(OR_context)): return projects.create(tenant_id=context.tenant_id, user_id=context.user_id, data=data) diff --git a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql index c3a732fc8..a3d403b44 100644 --- a/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/ee/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -497,21 +497,6 @@ $$ CREATE INDEX IF NOT EXISTS user_viewed_errors_user_id_idx ON public.user_viewed_errors (user_id); CREATE INDEX IF NOT EXISTS user_viewed_errors_error_id_idx ON public.user_viewed_errors (error_id); - CREATE TABLE IF NOT EXISTS errors_tags - ( - key text NOT NULL, - value text NOT NULL, - created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'), - error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE, - session_id bigint NOT NULL, - message_id bigint NOT NULL, - FOREIGN KEY (session_id, message_id) REFERENCES events.errors (session_id, message_id) ON DELETE CASCADE - ); - - CREATE INDEX IF NOT EXISTS errors_tags_error_id_idx ON errors_tags (error_id); - CREATE INDEX IF NOT EXISTS errors_tags_session_id_idx ON errors_tags (session_id); - CREATE INDEX IF NOT EXISTS errors_tags_message_id_idx ON errors_tags (message_id); - IF NOT EXISTS(SELECT * FROM pg_type typ WHERE typ.typname = 'platform') THEN @@ -1033,6 +1018,21 @@ $$ CREATE INDEX IF NOT EXISTS errors_error_id_timestamp_session_id_idx ON events.errors (error_id, timestamp, session_id); CREATE INDEX IF NOT EXISTS errors_error_id_idx ON events.errors (error_id); + CREATE TABLE IF NOT EXISTS errors_tags + ( + key text NOT NULL, + value text NOT NULL, + created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'), + error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE, + session_id bigint NOT NULL, + message_id bigint NOT NULL, + FOREIGN KEY (session_id, message_id) REFERENCES events.errors (session_id, message_id) ON DELETE CASCADE + ); + + CREATE INDEX IF NOT EXISTS errors_tags_error_id_idx ON errors_tags (error_id); + CREATE INDEX IF NOT EXISTS errors_tags_session_id_idx ON errors_tags (session_id); + CREATE INDEX IF NOT EXISTS errors_tags_message_id_idx ON errors_tags (message_id); + IF NOT EXISTS(SELECT * FROM pg_type typ WHERE typ.typname = 'http_method') THEN diff --git a/scripts/helm/db/init_dbs/postgresql/init_schema.sql b/scripts/helm/db/init_dbs/postgresql/init_schema.sql index 645696eeb..7652b3abe 100644 --- a/scripts/helm/db/init_dbs/postgresql/init_schema.sql +++ b/scripts/helm/db/init_dbs/postgresql/init_schema.sql @@ -405,20 +405,6 @@ $$ CREATE INDEX user_viewed_errors_user_id_idx ON public.user_viewed_errors (user_id); CREATE INDEX user_viewed_errors_error_id_idx ON public.user_viewed_errors (error_id); - CREATE TABLE errors_tags - ( - key text NOT NULL, - value text NOT NULL, - created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'), - error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE, - session_id bigint NOT NULL, - message_id bigint NOT NULL, - FOREIGN KEY (session_id, message_id) REFERENCES events.errors (session_id, message_id) ON DELETE CASCADE - ); - - CREATE INDEX errors_tags_error_id_idx ON errors_tags (error_id); - CREATE INDEX errors_tags_session_id_idx ON errors_tags (session_id); - CREATE INDEX errors_tags_message_id_idx ON errors_tags (message_id); -- --- sessions.sql --- CREATE TYPE device_type AS ENUM ('desktop', 'tablet', 'mobile', 'other'); @@ -750,6 +736,21 @@ $$ CREATE INDEX errors_error_id_timestamp_session_id_idx ON events.errors (error_id, timestamp, session_id); CREATE INDEX errors_error_id_idx ON events.errors (error_id); + CREATE TABLE errors_tags + ( + key text NOT NULL, + value text NOT NULL, + created_at timestamp without time zone NOT NULL default (now() at time zone 'utc'), + error_id text NOT NULL REFERENCES errors (error_id) ON DELETE CASCADE, + session_id bigint NOT NULL, + message_id bigint NOT NULL, + FOREIGN KEY (session_id, message_id) REFERENCES events.errors (session_id, message_id) ON DELETE CASCADE + ); + + CREATE INDEX errors_tags_error_id_idx ON errors_tags (error_id); + CREATE INDEX errors_tags_session_id_idx ON errors_tags (session_id); + CREATE INDEX errors_tags_message_id_idx ON errors_tags (message_id); + CREATE TABLE events.graphql ( session_id bigint NOT NULL REFERENCES sessions (session_id) ON DELETE CASCADE, diff --git a/scripts/helm/db/install.sh b/scripts/helm/db/install.sh index 15ff75a3b..e0c719ee8 100644 --- a/scripts/helm/db/install.sh +++ b/scripts/helm/db/install.sh @@ -79,7 +79,7 @@ for file in $(ls *.sql); do echo -e ${green}${bold}Restoring $file ${reset} kubectl exec postgresql-postgresql-0 -- /bin/bash -c "rm -rf /tmp/$file" kubectl cp $file postgresql-postgresql-0:/tmp/ - kubectl exec postgresql-postgresql-0 -- /bin/bash -c "PGPASSWORD=asayerPostgres psql -U postgres -f /tmp/$file" &> $cwd/postgresql_init.log + kubectl exec postgresql-postgresql-0 -- /bin/bash -c "PGPASSWORD=asayerPostgres psql -v ON_ERROR_STOP=1 -U postgres -f /tmp/$file" &> $cwd/postgresql_init.log echo -e ${green}${bold}Done ✔${reset} done cd $cwd diff --git a/scripts/helm/db/postgresql/README.md b/scripts/helm/db/postgresql/README.md index 8cdb2ca13..21a04c876 100755 --- a/scripts/helm/db/postgresql/README.md +++ b/scripts/helm/db/postgresql/README.md @@ -689,7 +689,7 @@ This operation could take some time depending on the database size. - Once you have the backup file, you can restore it with a command like the one below: ```console -$ psql -U postgres DATABASE_NAME < /tmp/backup.sql +$ psql -v ON_ERROR_STOP=1 -U postgres DATABASE_NAME < /tmp/backup.sql ``` In this case, you are accessing to the local postgresql, so the password should be the new one (you can find it in NOTES.txt). diff --git a/scripts/helm/migration.yaml b/scripts/helm/migration.yaml index abd4e571a..d3d5f4c80 100644 --- a/scripts/helm/migration.yaml +++ b/scripts/helm/migration.yaml @@ -18,7 +18,7 @@ file="{{ item|basename }}" kubectl exec -n db postgresql-postgresql-0 -- /bin/bash -c "rm -rf /tmp/$file" kubectl cp -n db {{ item }} postgresql-postgresql-0:/tmp/ - kubectl exec -n db postgresql-postgresql-0 -- /bin/bash -c "PGPASSWORD=asayerPostgres psql -U postgres -f /tmp/$file" &> "{{ playbook_dir }}"/postgresql_init.log + kubectl exec -n db postgresql-postgresql-0 -- /bin/bash -c "PGPASSWORD=asayerPostgres psql -v ON_ERROR_STOP=1 -U postgres -f /tmp/$file" &> "{{ playbook_dir }}"/postgresql_init.log args: chdir: db/init_dbs/postgresql with_fileglob: "{{ db_path }}" diff --git a/scripts/helmcharts/databases/charts/postgresql/README.md b/scripts/helmcharts/databases/charts/postgresql/README.md index 8cdb2ca13..21a04c876 100755 --- a/scripts/helmcharts/databases/charts/postgresql/README.md +++ b/scripts/helmcharts/databases/charts/postgresql/README.md @@ -689,7 +689,7 @@ This operation could take some time depending on the database size. - Once you have the backup file, you can restore it with a command like the one below: ```console -$ psql -U postgres DATABASE_NAME < /tmp/backup.sql +$ psql -v ON_ERROR_STOP=1 -U postgres DATABASE_NAME < /tmp/backup.sql ``` In this case, you are accessing to the local postgresql, so the password should be the new one (you can find it in NOTES.txt). diff --git a/scripts/helmcharts/openreplay/files/postgresql.sh b/scripts/helmcharts/openreplay/files/postgresql.sh index a641e4650..f2e89b6bd 100644 --- a/scripts/helmcharts/openreplay/files/postgresql.sh +++ b/scripts/helmcharts/openreplay/files/postgresql.sh @@ -17,13 +17,13 @@ function migrate() { IFS=',' read -r -a migration_versions <<< "$1" for version in ${migration_versions[*]}; do echo "Migrating postgresql version $version" - psql -f ${pgdir}/${version}/${version}.sql 2>&1 + psql -v ON_ERROR_STOP=1 -f ${pgdir}/${version}/${version}.sql 2>&1 done } function init() { echo "Initializing postgresql" - psql -f ${pgdir}/init_schema.sql 2>&1 + psql -v ON_ERROR_STOP=1 -f ${pgdir}/init_schema.sql 2>&1 } # /bin/bash postgresql.sh migrate $migration_versions