From 2ffc6ba42af4742a13b77543142b66b3e826ab88 Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Sun, 24 Aug 2025 18:29:41 +0200 Subject: [PATCH] fix: don't force uuid for client id in postgres --- .../20250824164821_client_id_type.down.sql | 1 + .../20250824164821_client_id_type.up.sql | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 backend/resources/migrations/postgres/20250824164821_client_id_type.down.sql create mode 100644 backend/resources/migrations/postgres/20250824164821_client_id_type.up.sql diff --git a/backend/resources/migrations/postgres/20250824164821_client_id_type.down.sql b/backend/resources/migrations/postgres/20250824164821_client_id_type.down.sql new file mode 100644 index 00000000..acbb90e3 --- /dev/null +++ b/backend/resources/migrations/postgres/20250824164821_client_id_type.down.sql @@ -0,0 +1 @@ +-- No-op because strings can't be converted to UUIDs \ No newline at end of file diff --git a/backend/resources/migrations/postgres/20250824164821_client_id_type.up.sql b/backend/resources/migrations/postgres/20250824164821_client_id_type.up.sql new file mode 100644 index 00000000..8c38c60f --- /dev/null +++ b/backend/resources/migrations/postgres/20250824164821_client_id_type.up.sql @@ -0,0 +1,57 @@ +-- Drop foreign keys that reference oidc_clients(id) +ALTER TABLE oidc_authorization_codes + DROP CONSTRAINT IF EXISTS oidc_authorization_codes_client_fk; +ALTER TABLE user_authorized_oidc_clients + DROP CONSTRAINT IF EXISTS user_authorized_oidc_clients_client_id_fkey; +ALTER TABLE oidc_refresh_tokens + DROP CONSTRAINT IF EXISTS oidc_refresh_tokens_client_id_fkey; +ALTER TABLE oidc_device_codes + DROP CONSTRAINT IF EXISTS oidc_device_codes_client_id_fkey; +ALTER TABLE oidc_clients_allowed_user_groups + DROP CONSTRAINT IF EXISTS oidc_clients_allowed_user_groups_oidc_client_id_fkey; + +-- Alter child columns to varchar(128) +ALTER TABLE oidc_authorization_codes + ALTER COLUMN client_id TYPE varchar(128) USING client_id::text; + +ALTER TABLE user_authorized_oidc_clients + ALTER + COLUMN client_id TYPE varchar(128) USING client_id::text; + +ALTER TABLE oidc_refresh_tokens + ALTER + COLUMN client_id TYPE varchar(128) USING client_id::text; + +ALTER TABLE oidc_device_codes + ALTER + COLUMN client_id TYPE varchar(128) USING client_id::text; + +ALTER TABLE oidc_clients_allowed_user_groups + ALTER + COLUMN oidc_client_id TYPE varchar(128) USING oidc_client_id::text; + +-- Alter parent primary key column to varchar(128) +ALTER TABLE oidc_clients + ALTER + COLUMN id TYPE varchar(128) USING id::text; + +-- Recreate foreign keys with the new type +ALTER TABLE oidc_authorization_codes + ADD CONSTRAINT oidc_authorization_codes_client_fk + FOREIGN KEY (client_id) REFERENCES oidc_clients (id) ON DELETE CASCADE; + +ALTER TABLE user_authorized_oidc_clients + ADD CONSTRAINT user_authorized_oidc_clients_client_id_fkey + FOREIGN KEY (client_id) REFERENCES oidc_clients (id) ON DELETE CASCADE; + +ALTER TABLE oidc_refresh_tokens + ADD CONSTRAINT oidc_refresh_tokens_client_id_fkey + FOREIGN KEY (client_id) REFERENCES oidc_clients (id) ON DELETE CASCADE; + +ALTER TABLE oidc_device_codes + ADD CONSTRAINT oidc_device_codes_client_id_fkey + FOREIGN KEY (client_id) REFERENCES oidc_clients (id) ON DELETE CASCADE; + +ALTER TABLE oidc_clients_allowed_user_groups + ADD CONSTRAINT oidc_clients_allowed_user_groups_oidc_client_id_fkey + FOREIGN KEY (oidc_client_id) REFERENCES oidc_clients (id) ON DELETE CASCADE; \ No newline at end of file