From 42d0a2749a3d1eb9e9364957e5a2aac52a0a87ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Sun, 5 Apr 2026 14:22:09 +0200 Subject: [PATCH] Clarify migration comment: nullable-first is about NOT NULL without DEFAULT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw Made-with: Cursor --- .../migrations/20260403000000_add_location_entity_ref.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/catalog-backend/migrations/20260403000000_add_location_entity_ref.js b/plugins/catalog-backend/migrations/20260403000000_add_location_entity_ref.js index 1beafb91d0..6278e297c7 100644 --- a/plugins/catalog-backend/migrations/20260403000000_add_location_entity_ref.js +++ b/plugins/catalog-backend/migrations/20260403000000_add_location_entity_ref.js @@ -33,8 +33,10 @@ const MYSQL_BATCH_SIZE = 1000; * removed in a future migration) gets an empty string as a placeholder value. * * The migration adds the column as nullable first, fills every row, then - * tightens it to NOT NULL. This avoids the MySQL strict-mode restriction that - * TEXT columns cannot have DEFAULT values. + * tightens it to NOT NULL. Adding a NOT NULL column to a non-empty table + * requires a DEFAULT so the database can back-fill existing rows; supplying a + * sentinel default here would be misleading, so instead we add the column as + * nullable, fill every row with its real value, then tighten the constraint. * * Postgres: single `UPDATE … FROM unnest(ids::uuid[], refs::text[])` for all * rows — the SQL text is fixed-size and the planner does an index