From 18cc521b1611ad286f518dea796db23c3d66bab6 Mon Sep 17 00:00:00 2001 From: Ladislav Sulak Date: Wed, 30 Sep 2026 17:26:13 +0200 Subject: [PATCH 1/2] adding forgotten PK columns and thus also grants for the writer --- .../migrations/V1.4.0.4__adding_table_pks.ddl | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 database/migrations/V1.4.0.4__adding_table_pks.ddl diff --git a/database/migrations/V1.4.0.4__adding_table_pks.ddl b/database/migrations/V1.4.0.4__adding_table_pks.ddl new file mode 100644 index 0000000..f2a9d03 --- /dev/null +++ b/database/migrations/V1.4.0.4__adding_table_pks.ddl @@ -0,0 +1,22 @@ +/* + * Copyright 2026 ABSA Group Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +-- Forgotten columns (PKs) from the previous DDLs. +ALTER TABLE public.public_cps_za_runs ADD COLUMN IF NOT EXISTS internal_id SERIAL PRIMARY KEY; +ALTER TABLE public.public_cps_za_dlchange ADD COLUMN IF NOT EXISTS internal_id SERIAL PRIMARY KEY; + +-- Writer needs the SERIAL sequence permissions to insert into the relevant tables. +GRANT USAGE, SELECT ON SEQUENCE public.public_cps_za_runs_internal_id_seq TO eventgate_writer; +GRANT USAGE, SELECT ON SEQUENCE public.public_cps_za_dlchange_internal_id_seq TO eventgate_writer; From e5d19227466010a4c9c8c86e28c00e320040fae5 Mon Sep 17 00:00:00 2001 From: Ladislav Sulak Date: Wed, 30 Sep 2026 17:44:03 +0200 Subject: [PATCH 2/2] I am forced to run flyway repair on DEV anyway, so editing existing files --- .../migrations/V1.4.0.2__initial_schema.ddl | 2 ++ database/migrations/V1.4.0.3__grants.ddl | 2 ++ .../migrations/V1.4.0.4__adding_table_pks.ddl | 22 ------------------- 3 files changed, 4 insertions(+), 22 deletions(-) delete mode 100644 database/migrations/V1.4.0.4__adding_table_pks.ddl diff --git a/database/migrations/V1.4.0.2__initial_schema.ddl b/database/migrations/V1.4.0.2__initial_schema.ddl index 3740825..7551417 100644 --- a/database/migrations/V1.4.0.2__initial_schema.ddl +++ b/database/migrations/V1.4.0.2__initial_schema.ddl @@ -17,6 +17,7 @@ -- Run header rows for the runs topic. CREATE TABLE IF NOT EXISTS public_cps_za_runs ( + internal_id SERIAL PRIMARY KEY, event_id VARCHAR(255) NOT NULL, job_ref VARCHAR(255) NOT NULL, tenant_id VARCHAR(255) NOT NULL, @@ -42,6 +43,7 @@ CREATE TABLE IF NOT EXISTS public_cps_za_runs_jobs ( -- Data lake change events. CREATE TABLE IF NOT EXISTS public_cps_za_dlchange ( + internal_id SERIAL PRIMARY KEY, event_id VARCHAR(255) NOT NULL, tenant_id VARCHAR(255) NOT NULL, source_app VARCHAR(255) NOT NULL, diff --git a/database/migrations/V1.4.0.3__grants.ddl b/database/migrations/V1.4.0.3__grants.ddl index c61b563..770e85d 100644 --- a/database/migrations/V1.4.0.3__grants.ddl +++ b/database/migrations/V1.4.0.3__grants.ddl @@ -47,7 +47,9 @@ GRANT SELECT, INSERT, UPDATE ON TABLE TO eventgate_writer; -- Writer needs the SERIAL sequence (public_cps_za_runs_jobs.internal_id) to insert. +GRANT USAGE, SELECT ON SEQUENCE public.public_cps_za_runs_internal_id_seq TO eventgate_writer; GRANT USAGE, SELECT ON SEQUENCE public.public_cps_za_runs_jobs_internal_id_seq TO eventgate_writer; +GRANT USAGE, SELECT ON SEQUENCE public.public_cps_za_dlchange_internal_id_seq TO eventgate_writer; -- Default privileges for objects the owner creates in the future. -- Executed as eventgate_owner: on managed Postgres (Aurora/RDS) the migration user is not a true superuser diff --git a/database/migrations/V1.4.0.4__adding_table_pks.ddl b/database/migrations/V1.4.0.4__adding_table_pks.ddl deleted file mode 100644 index f2a9d03..0000000 --- a/database/migrations/V1.4.0.4__adding_table_pks.ddl +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2026 ABSA Group Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - --- Forgotten columns (PKs) from the previous DDLs. -ALTER TABLE public.public_cps_za_runs ADD COLUMN IF NOT EXISTS internal_id SERIAL PRIMARY KEY; -ALTER TABLE public.public_cps_za_dlchange ADD COLUMN IF NOT EXISTS internal_id SERIAL PRIMARY KEY; - --- Writer needs the SERIAL sequence permissions to insert into the relevant tables. -GRANT USAGE, SELECT ON SEQUENCE public.public_cps_za_runs_internal_id_seq TO eventgate_writer; -GRANT USAGE, SELECT ON SEQUENCE public.public_cps_za_dlchange_internal_id_seq TO eventgate_writer;