From b79540a5a093eb27e5df43d09d848b27c3220e6e Mon Sep 17 00:00:00 2001 From: remyvdwereld <86827854+remyvdwereld@users.noreply.github.com> Date: Thu, 8 Feb 2024 15:51:40 +0100 Subject: [PATCH 1/2] Executed query for default id --- .../0024_alter_default_column_ids_azure.py | 47 +++++++++++++++++++ docker-compose.yml | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 app/apps/cases/migrations/0024_alter_default_column_ids_azure.py diff --git a/app/apps/cases/migrations/0024_alter_default_column_ids_azure.py b/app/apps/cases/migrations/0024_alter_default_column_ids_azure.py new file mode 100644 index 000000000..5dea2e77c --- /dev/null +++ b/app/apps/cases/migrations/0024_alter_default_column_ids_azure.py @@ -0,0 +1,47 @@ +# Generated by Django 3.2.13 on 2024-02-08 13:36 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("cases", "0023_add_multiple_tags"), + ] + + operations = [ + migrations.RunSQL( + sql=""" + DO $$ + BEGIN + -- cases_casetheme + IF NOT EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'S' AND c.relname = 'cases_casetheme_id_seq' AND n.nspname = 'public') THEN + CREATE SEQUENCE public.cases_casetheme_id_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 NO MAXVALUE CACHE 1; + END IF; + -- workflow_caseusertask + IF NOT EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'S' AND c.relname = 'workflow_caseusertask_id_seq' AND n.nspname = 'public') THEN + CREATE SEQUENCE public.workflow_caseusertask_id_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 NO MAXVALUE CACHE 1; + END IF; + -- workflow_caseworkflow + IF NOT EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'S' AND c.relname = 'workflow_caseworkflow_id_seq' AND n.nspname = 'public') THEN + CREATE SEQUENCE public.workflow_caseworkflow_id_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 NO MAXVALUE CACHE 1; + END IF; + -- schedules_action + IF NOT EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'S' AND c.relname = 'schedules_action_id_seq' AND n.nspname = 'public') THEN + CREATE SEQUENCE public.schedules_action_id_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 NO MAXVALUE CACHE 1; + END IF; + -- events_caseevent + IF NOT EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'S' AND c.relname = 'events_caseevent_id_seq' AND n.nspname = 'public') THEN + CREATE SEQUENCE public.events_caseevent_id_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 NO MAXVALUE CACHE 1; + END IF; + END + $$; + + ALTER TABLE cases_casetheme ALTER COLUMN id SET DEFAULT nextval('public.cases_casetheme_id_seq'::regclass); + ALTER TABLE workflow_caseusertask ALTER COLUMN id SET DEFAULT nextval('public.workflow_caseusertask_id_seq'::regclass); + ALTER TABLE workflow_caseworkflow ALTER COLUMN id SET DEFAULT nextval('public.workflow_caseworkflow_id_seq'::regclass); + ALTER TABLE schedules_action ALTER COLUMN id SET DEFAULT nextval('public.schedules_action_id_seq'::regclass); + ALTER TABLE events_caseevent ALTER COLUMN id SET DEFAULT nextval('public.events_caseevent_id_seq'::regclass); + """ + ) + ] diff --git a/docker-compose.yml b/docker-compose.yml index eed2bbf5b..89c57e8e9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -35,7 +35,7 @@ services: database: networks: - zaken_network - image: amsterdam/postgres11 + image: amsterdam/postgres12 shm_size: "512m" ports: - "6409:5432" From 37c62289bc1062bb193734b79030d60f6ba0ea3e Mon Sep 17 00:00:00 2001 From: remyvdwereld <86827854+remyvdwereld@users.noreply.github.com> Date: Thu, 8 Feb 2024 16:27:02 +0100 Subject: [PATCH 2/2] Updated migration for every app --- .../0024_alter_default_column_ids_azure.py | 20 ------------ .../0002_alter_default_column_ids_azure.py | 27 ++++++++++++++++ .../0005_alter_default_column_ids_azure.py | 27 ++++++++++++++++ .../0009_alter_default_column_ids_azure.py | 32 +++++++++++++++++++ 4 files changed, 86 insertions(+), 20 deletions(-) create mode 100644 app/apps/events/migrations/0002_alter_default_column_ids_azure.py create mode 100644 app/apps/schedules/migrations/0005_alter_default_column_ids_azure.py create mode 100644 app/apps/workflow/migrations/0009_alter_default_column_ids_azure.py diff --git a/app/apps/cases/migrations/0024_alter_default_column_ids_azure.py b/app/apps/cases/migrations/0024_alter_default_column_ids_azure.py index 5dea2e77c..10842dfce 100644 --- a/app/apps/cases/migrations/0024_alter_default_column_ids_azure.py +++ b/app/apps/cases/migrations/0024_alter_default_column_ids_azure.py @@ -18,30 +18,10 @@ class Migration(migrations.Migration): IF NOT EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'S' AND c.relname = 'cases_casetheme_id_seq' AND n.nspname = 'public') THEN CREATE SEQUENCE public.cases_casetheme_id_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 NO MAXVALUE CACHE 1; END IF; - -- workflow_caseusertask - IF NOT EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'S' AND c.relname = 'workflow_caseusertask_id_seq' AND n.nspname = 'public') THEN - CREATE SEQUENCE public.workflow_caseusertask_id_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 NO MAXVALUE CACHE 1; - END IF; - -- workflow_caseworkflow - IF NOT EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'S' AND c.relname = 'workflow_caseworkflow_id_seq' AND n.nspname = 'public') THEN - CREATE SEQUENCE public.workflow_caseworkflow_id_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 NO MAXVALUE CACHE 1; - END IF; - -- schedules_action - IF NOT EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'S' AND c.relname = 'schedules_action_id_seq' AND n.nspname = 'public') THEN - CREATE SEQUENCE public.schedules_action_id_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 NO MAXVALUE CACHE 1; - END IF; - -- events_caseevent - IF NOT EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'S' AND c.relname = 'events_caseevent_id_seq' AND n.nspname = 'public') THEN - CREATE SEQUENCE public.events_caseevent_id_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 NO MAXVALUE CACHE 1; - END IF; END $$; ALTER TABLE cases_casetheme ALTER COLUMN id SET DEFAULT nextval('public.cases_casetheme_id_seq'::regclass); - ALTER TABLE workflow_caseusertask ALTER COLUMN id SET DEFAULT nextval('public.workflow_caseusertask_id_seq'::regclass); - ALTER TABLE workflow_caseworkflow ALTER COLUMN id SET DEFAULT nextval('public.workflow_caseworkflow_id_seq'::regclass); - ALTER TABLE schedules_action ALTER COLUMN id SET DEFAULT nextval('public.schedules_action_id_seq'::regclass); - ALTER TABLE events_caseevent ALTER COLUMN id SET DEFAULT nextval('public.events_caseevent_id_seq'::regclass); """ ) ] diff --git a/app/apps/events/migrations/0002_alter_default_column_ids_azure.py b/app/apps/events/migrations/0002_alter_default_column_ids_azure.py new file mode 100644 index 000000000..0d73b1725 --- /dev/null +++ b/app/apps/events/migrations/0002_alter_default_column_ids_azure.py @@ -0,0 +1,27 @@ +# Generated by Django 3.2.13 on 2024-02-08 15:19 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("events", "0001_initial"), + ] + + operations = [ + migrations.RunSQL( + sql=""" + DO $$ + BEGIN + -- events_caseevent + IF NOT EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'S' AND c.relname = 'events_caseevent_id_seq' AND n.nspname = 'public') THEN + CREATE SEQUENCE public.events_caseevent_id_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 NO MAXVALUE CACHE 1; + END IF; + END + $$; + + ALTER TABLE events_caseevent ALTER COLUMN id SET DEFAULT nextval('public.events_caseevent_id_seq'::regclass); + """ + ) + ] diff --git a/app/apps/schedules/migrations/0005_alter_default_column_ids_azure.py b/app/apps/schedules/migrations/0005_alter_default_column_ids_azure.py new file mode 100644 index 000000000..770023ca2 --- /dev/null +++ b/app/apps/schedules/migrations/0005_alter_default_column_ids_azure.py @@ -0,0 +1,27 @@ +# Generated by Django 3.2.13 on 2024-02-08 15:19 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("schedules", "0004_schedule_housing_corporation_combiteam"), + ] + + operations = [ + migrations.RunSQL( + sql=""" + DO $$ + BEGIN + -- schedules_action + IF NOT EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'S' AND c.relname = 'schedules_action_id_seq' AND n.nspname = 'public') THEN + CREATE SEQUENCE public.schedules_action_id_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 NO MAXVALUE CACHE 1; + END IF; + END + $$; + + ALTER TABLE schedules_action ALTER COLUMN id SET DEFAULT nextval('public.schedules_action_id_seq'::regclass); + """ + ) + ] diff --git a/app/apps/workflow/migrations/0009_alter_default_column_ids_azure.py b/app/apps/workflow/migrations/0009_alter_default_column_ids_azure.py new file mode 100644 index 000000000..5c4e31bd1 --- /dev/null +++ b/app/apps/workflow/migrations/0009_alter_default_column_ids_azure.py @@ -0,0 +1,32 @@ +# Generated by Django 3.2.13 on 2024-02-08 15:19 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("workflow", "0008_workflowoption_enabled_on_case_closed"), + ] + + operations = [ + migrations.RunSQL( + sql=""" + DO $$ + BEGIN + -- workflow_caseusertask + IF NOT EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'S' AND c.relname = 'workflow_caseusertask_id_seq' AND n.nspname = 'public') THEN + CREATE SEQUENCE public.workflow_caseusertask_id_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 NO MAXVALUE CACHE 1; + END IF; + -- workflow_caseworkflow + IF NOT EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'S' AND c.relname = 'workflow_caseworkflow_id_seq' AND n.nspname = 'public') THEN + CREATE SEQUENCE public.workflow_caseworkflow_id_seq INCREMENT BY 1 START WITH 1 MINVALUE 1 NO MAXVALUE CACHE 1; + END IF; + END + $$; + + ALTER TABLE workflow_caseusertask ALTER COLUMN id SET DEFAULT nextval('public.workflow_caseusertask_id_seq'::regclass); + ALTER TABLE workflow_caseworkflow ALTER COLUMN id SET DEFAULT nextval('public.workflow_caseworkflow_id_seq'::regclass); + """ + ) + ]