From a70713509f084a1d33840dae7e71a4d876bdb3db Mon Sep 17 00:00:00 2001 From: Igor Polyakov Date: Wed, 19 Jun 2024 15:00:03 +0300 Subject: [PATCH] sync --- Makefile | 2 +- internal/app/database/update0013_update0014.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cb8fd12..cdac291 100644 --- a/Makefile +++ b/Makefile @@ -75,7 +75,7 @@ remove-db: # Attach to the running PostgreSQL container attach-db: - docker exec -it ctf01d-postgres psql -U postgres + docker exec -it ctf01d-postgres psql -U postgres -d ctf01d_training_platform # Generate Go server boilerplate from OpenAPI 3 codegen: diff --git a/internal/app/database/update0013_update0014.go b/internal/app/database/update0013_update0014.go index 1e5ed5f..d773dfe 100644 --- a/internal/app/database/update0013_update0014.go +++ b/internal/app/database/update0013_update0014.go @@ -86,6 +86,21 @@ func DatabaseUpdate_update0013_update0014(db *sql.DB, getInfo bool) (string, str ALTER TABLE game_services RENAME COLUMN new_service_id TO service_id; + ALTER TABLE sessions DROP CONSTRAINT sessions_user_id_fkey; + ALTER TABLE sessions DROP COLUMN id; + ALTER TABLE sessions RENAME COLUMN new_id TO id; + + + ALTER TABLE teams DROP CONSTRAINT teams_user_id_fkey; + ALTER TABLE teams DROP COLUMN id; + ALTER TABLE teams RENAME COLUMN new_id TO id; + + + ALTER TABLE games DROP CONSTRAINT games_user_id_fkey; + ALTER TABLE games DROP COLUMN id; + ALTER TABLE games RENAME COLUMN new_id TO id; + + COMMIT; ` _, err := db.Exec(query)