Files
fitme3070.pt/database/migration_20260612_website_offer_softdelete.sql
2026-06-12 21:20:23 +01:00

16 lines
806 B
SQL

-- ─── website_offer soft-delete: drop the zero-date (D4) ─────────────────────
-- o_deleted_at was datetime NOT NULL, so "not deleted" rows carried the invalid
-- zero-date '0000-00-00 00:00:00' (rejected under NO_ZERO_DATE/strict mode) and
-- the app had to filter for it explicitly. Make it nullable and normalise the
-- existing zero-dates to NULL, aligning with every other table's deleted_at.
ALTER TABLE `website_offer`
MODIFY `o_deleted_at` DATETIME NULL DEFAULT NULL;
-- Normalise legacy "not deleted" markers to NULL. Comparing against a literal
-- zero-date is itself unsafe under strict mode, so match by year 0 instead.
UPDATE `website_offer`
SET `o_deleted_at` = NULL
WHERE `o_deleted_at` IS NOT NULL
AND YEAR(`o_deleted_at`) = 0;