Skip to content

Conversation

@julianbrost
Copy link
Collaborator

@julianbrost julianbrost commented Nov 13, 2025

This gives a single file that can be applied during the upgrade more easily, having it in individual files was mostly to avoid merge conflicts during development.

The combined files were created with the following command:

cat 0.2.0-external-uuid.sql <(echo) 0.2.0-source-rules.sql <(echo) 0.2.0-schedule-timezone.sql <(echo) 0.2.0-source-username.sql > 0.2.0.sql

The order of files matches the order in which the PRs that added them were merged (though the order shouldn't really matter as there are no dependencies between the individual files):

fixes #350

This gives a single file that can be applied during the upgrade more easily,
having it in individual files was mostly to avoid merge conflicts during
development.

The combined files were created with the following command:

  cat 0.2.0-external-uuid.sql <(echo) 0.2.0-source-rules.sql <(echo) 0.2.0-schedule-timezone.sql <(echo) 0.2.0-source-username.sql > 0.2.0.sql

The order of files matches the order in which the PRs that added them were
merged (though the order shouldn't really matter as there are no dependencies
between the individual files):

 - #216
 - #324
 - #344
 - #338
@julianbrost julianbrost added this to the 0.2.0 milestone Nov 13, 2025
@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Nov 13, 2025
Copy link
Member

@oxzi oxzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MariaDB schema diff
--- eikaex4A_mariadb_schema_import.sql  2025-11-13 11:16:03.582316922 +0100
+++ eikaex4A_mariadb_schema_upgrade.sql 2025-11-13 11:16:02.433093167 +0100
@@ -665,8 +665,8 @@
   `deleted` enum('n','y') NOT NULL DEFAULT 'n',
   PRIMARY KEY (`id`),
   KEY `fk_rule_timeperiod` (`timeperiod_id`),
-  KEY `fk_rule_source` (`source_id`),
   KEY `idx_rule_changed_at` (`changed_at`),
+  KEY `fk_rule_source` (`source_id`),
   CONSTRAINT `fk_rule_source` FOREIGN KEY (`source_id`) REFERENCES `source` (`id`),
   CONSTRAINT `fk_rule_timeperiod` FOREIGN KEY (`timeperiod_id`) REFERENCES `timeperiod` (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
@@ -811,8 +811,8 @@
   PRIMARY KEY (`id`),
   UNIQUE KEY `uk_source_listener_username` (`listener_username`),
   KEY `idx_source_changed_at` (`changed_at`),
-  CONSTRAINT `ck_source_listener_username_or_deleted` CHECK (`deleted` = 'y' or `listener_username` is not null),
-  CONSTRAINT `ck_source_bcrypt_listener_password_hash` CHECK (`listener_password_hash` is null or `listener_password_hash` like '$2_$%')
+  CONSTRAINT `ck_source_bcrypt_listener_password_hash` CHECK (`listener_password_hash` is null or `listener_password_hash` like '$2_$%'),
+  CONSTRAINT `ck_source_listener_username_or_deleted` CHECK (`deleted` = 'y' or `listener_username` is not null)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
 /*!40101 SET character_set_client = @saved_cs_client */;

@@ -904,4 +904,4 @@
 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
 /*M!100616 SET NOTE_VERBOSITY=@OLD_NOTE_VERBOSITY */;

--- Dump completed on 2025-11-13 10:16:03
+-- Dump completed on 2025-11-13 10:16:02

The MariaDB/MySQL diff looks fine. Just the order of two constraints differs.

PostgreSQL schema diff
--- eikaex4A_postgresql_schema_import.sql	2025-11-13 11:16:03.678098167 +0100
+++ eikaex4A_postgresql_schema_upgrade.sql	2025-11-13 11:16:02.542093604 +0100
@@ -2,7 +2,7 @@
 -- PostgreSQL database dump
 --
 
-\restrict X5PTq9FhM2c6xp3MgUsFZcLEGikS8mTeSJh7HF3pVAdjol72lNeoVVzfESktpiT
+\restrict DdbMWpUzmkLOZ4g7ELlopoj7tJgMtRNmloPhpWt1GNUT9Z3WPolcBSc8rWJR3rL
 
 -- Dumped from database version 18.0 (Debian 18.0-1.pgdg13+3)
 -- Dumped by pg_dump version 18.0 (Debian 18.0-1.pgdg13+3)
@@ -213,12 +213,12 @@
 
 CREATE TABLE public.channel (
     id bigint NOT NULL,
-    external_uuid uuid NOT NULL,
     name public.citext NOT NULL,
     type character varying(255) NOT NULL,
     config text,
     changed_at bigint NOT NULL,
-    deleted public.boolenum DEFAULT 'n'::public.boolenum NOT NULL
+    deleted public.boolenum DEFAULT 'n'::public.boolenum NOT NULL,
+    external_uuid uuid NOT NULL
 );
 
 
@@ -251,12 +251,12 @@
 
 CREATE TABLE public.contact (
     id bigint NOT NULL,
-    external_uuid uuid NOT NULL,
     full_name public.citext NOT NULL,
     username public.citext,
     default_channel_id bigint NOT NULL,
     changed_at bigint NOT NULL,
     deleted public.boolenum DEFAULT 'n'::public.boolenum NOT NULL,
+    external_uuid uuid NOT NULL,
     CONSTRAINT ck_contact_username_up_to_254_chars CHECK ((length((username)::text) <= 254))
 );
 
@@ -327,10 +327,10 @@
 
 CREATE TABLE public.contactgroup (
     id bigint NOT NULL,
-    external_uuid uuid NOT NULL,
     name public.citext NOT NULL,
     changed_at bigint NOT NULL,
-    deleted public.boolenum DEFAULT 'n'::public.boolenum NOT NULL
+    deleted public.boolenum DEFAULT 'n'::public.boolenum NOT NULL,
+    external_uuid uuid NOT NULL
 );
 
 
@@ -681,10 +681,10 @@
     id bigint NOT NULL,
     name public.citext NOT NULL,
     timeperiod_id bigint,
-    source_id bigint NOT NULL,
     object_filter text,
     changed_at bigint NOT NULL,
-    deleted public.boolenum DEFAULT 'n'::public.boolenum NOT NULL
+    deleted public.boolenum DEFAULT 'n'::public.boolenum NOT NULL,
+    source_id bigint NOT NULL
 );
 
 
@@ -799,9 +799,9 @@
 CREATE TABLE public.schedule (
     id bigint NOT NULL,
     name public.citext NOT NULL,
-    timezone text NOT NULL,
     changed_at bigint NOT NULL,
-    deleted public.boolenum DEFAULT 'n'::public.boolenum NOT NULL
+    deleted public.boolenum DEFAULT 'n'::public.boolenum NOT NULL,
+    timezone text NOT NULL
 );
 
 
@@ -836,10 +836,10 @@
     id bigint NOT NULL,
     type text NOT NULL,
     name public.citext NOT NULL,
-    listener_username character varying(255),
     listener_password_hash text,
     changed_at bigint NOT NULL,
     deleted public.boolenum DEFAULT 'n'::public.boolenum NOT NULL,
+    listener_username character varying(255),
     CONSTRAINT ck_source_bcrypt_listener_password_hash CHECK (((listener_password_hash IS NULL) OR (listener_password_hash ~~ '$2_$%'::text))),
     CONSTRAINT ck_source_listener_username_or_deleted CHECK (((deleted = 'y'::public.boolenum) OR (listener_username IS NOT NULL)))
 );
@@ -1076,7 +1076,7 @@
 -- Data for Name: channel; Type: TABLE DATA; Schema: public; Owner: postgres
 --
 
-COPY public.channel (id, external_uuid, name, type, config, changed_at, deleted) FROM stdin;
+COPY public.channel (id, name, type, config, changed_at, deleted, external_uuid) FROM stdin;
 \.
 
 
@@ -1084,7 +1084,7 @@
 -- Data for Name: contact; Type: TABLE DATA; Schema: public; Owner: postgres
 --
 
-COPY public.contact (id, external_uuid, full_name, username, default_channel_id, changed_at, deleted) FROM stdin;
+COPY public.contact (id, full_name, username, default_channel_id, changed_at, deleted, external_uuid) FROM stdin;
 \.
 
 
@@ -1100,7 +1100,7 @@
 -- Data for Name: contactgroup; Type: TABLE DATA; Schema: public; Owner: postgres
 --
 
-COPY public.contactgroup (id, external_uuid, name, changed_at, deleted) FROM stdin;
+COPY public.contactgroup (id, name, changed_at, deleted, external_uuid) FROM stdin;
 \.
 
 
@@ -1212,7 +1212,7 @@
 -- Data for Name: rule; Type: TABLE DATA; Schema: public; Owner: postgres
 --
 
-COPY public.rule (id, name, timeperiod_id, source_id, object_filter, changed_at, deleted) FROM stdin;
+COPY public.rule (id, name, timeperiod_id, object_filter, changed_at, deleted, source_id) FROM stdin;
 \.
 
 
@@ -1236,7 +1236,7 @@
 -- Data for Name: schedule; Type: TABLE DATA; Schema: public; Owner: postgres
 --
 
-COPY public.schedule (id, name, timezone, changed_at, deleted) FROM stdin;
+COPY public.schedule (id, name, changed_at, deleted, timezone) FROM stdin;
 \.
 
 
@@ -1244,7 +1244,7 @@
 -- Data for Name: source; Type: TABLE DATA; Schema: public; Owner: postgres
 --
 
-COPY public.source (id, type, name, listener_username, listener_password_hash, changed_at, deleted) FROM stdin;
+COPY public.source (id, type, name, listener_password_hash, changed_at, deleted, listener_username) FROM stdin;
 \.
 
 
@@ -2170,5 +2170,5 @@
 -- PostgreSQL database dump complete
 --
 
-\unrestrict X5PTq9FhM2c6xp3MgUsFZcLEGikS8mTeSJh7HF3pVAdjol72lNeoVVzfESktpiT
+\unrestrict DdbMWpUzmkLOZ4g7ELlopoj7tJgMtRNmloPhpWt1GNUT9Z3WPolcBSc8rWJR3rL

The PostgreSQL schema diff looks fine as well. The order of new columns differs, but this is no problem as long as we don't start with any SELECT * madness.

@julianbrost julianbrost merged commit cf58325 into main Nov 13, 2025
26 checks passed
@julianbrost julianbrost deleted the merge-0.2.0-schema-upgrades branch November 13, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla/signed CLA is signed by all contributors of a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merge schema upgrade files

3 participants