From 6d1cd3b3b4ae20eced5f15ec8eab6b2d5cb4ceb7 Mon Sep 17 00:00:00 2001 From: David Croft Date: Sun, 19 Jul 2026 21:28:09 +1000 Subject: [PATCH] fix(scim): create a real MySQL foreign key for scim_api_key MySQL/InnoDB silently ignores inline column-level REFERENCES, so the original migration created no foreign key at all on MySQL. Use a table-level FOREIGN KEY clause and match organizations.uuid's VARCHAR(40) type exactly so the constraint is actually created. Co-Authored-By: Claude Fable 5 --- .../mysql/2026-07-19-000000_add_scim_api_key/up.sql | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/migrations/mysql/2026-07-19-000000_add_scim_api_key/up.sql b/migrations/mysql/2026-07-19-000000_add_scim_api_key/up.sql index ae42e2c6..40e4d360 100644 --- a/migrations/mysql/2026-07-19-000000_add_scim_api_key/up.sql +++ b/migrations/mysql/2026-07-19-000000_add_scim_api_key/up.sql @@ -1,8 +1,12 @@ +-- org_uuid is VARCHAR(40) to match organizations.uuid exactly; the FOREIGN KEY +-- must be a table-level clause because MySQL silently ignores inline +-- column-level REFERENCES. CREATE TABLE scim_api_key ( uuid CHAR(36) NOT NULL PRIMARY KEY, - org_uuid CHAR(36) NOT NULL UNIQUE REFERENCES organizations(uuid), + org_uuid VARCHAR(40) NOT NULL UNIQUE, key_hash VARCHAR(255) NOT NULL, enabled BOOLEAN NOT NULL DEFAULT TRUE, created_at DATETIME NOT NULL, - revision_date DATETIME NOT NULL + revision_date DATETIME NOT NULL, + FOREIGN KEY(org_uuid) REFERENCES organizations(uuid) );