Skip to content

[Bug] Data migration: guard zero-date/NULL legacy dates under STRICT sql_mode #123

@Salem874

Description

@Salem874

Problem

Migrations copy legacy date columns straight into NOT NULL createdAt/updatedAt under STRICT sql_mode. A single 0000-00-00/NULL legacy row aborts the whole transactional batch — risking the live 480-URL / 5-org / 7-user migration.

Affected

  • web/_sql/migrations/001_migrate_organisations.sql, 002_migrate_users.sql, 003_migrate_categories.sql, 004_migrate_shorturls.sql

Fix

Guard every legacy date, e.g. IFNULL(NULLIF(old.dateCol,'0000-00-00 00:00:00'), NOW()); or pre-clean source dates. Add a migrated-vs-source row-count assertion after COMMIT.

Acceptance criteria

  • Dry-run migration succeeds against a copy of legacy data containing zero/NULL dates.
  • Post-migration row counts match source counts.

From the 2026-06-04 schema review — see docs/SCHEMA_REVIEW_2026-06-04.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcomponent-databaseDatabase schema, migrations, procedurespriority-highHigh priority

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions