From 7d7d7c713ca81f5490da896bf12b6fe0e1ccea4d Mon Sep 17 00:00:00 2001 From: Cameron Cordes Date: Fri, 25 Sep 2026 15:39:23 -0400 Subject: [PATCH] refactor(dates): condense the two date-contract migrations into one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Neither migration had shipped, so the #115 snapshot columns join the #114 new-contract columns in 2026-09-24-000000_add_true_utc_dates. Pure ADD COLUMN either way — population is runtime (drains), so nothing needs re-migrating. Column order is unchanged, so schema.rs stands. --- .../down.sql | 3 +++ .../up.sql | 19 ++++++++++++++++--- .../down.sql | 3 --- .../up.sql | 13 ------------- 4 files changed, 19 insertions(+), 19 deletions(-) delete mode 100644 migrations/2026-09-25-000000_manual_date_triple_snapshot/down.sql delete mode 100644 migrations/2026-09-25-000000_manual_date_triple_snapshot/up.sql diff --git a/migrations/2026-09-24-000000_add_true_utc_dates/down.sql b/migrations/2026-09-24-000000_add_true_utc_dates/down.sql index e8d5992..722707b 100644 --- a/migrations/2026-09-24-000000_add_true_utc_dates/down.sql +++ b/migrations/2026-09-24-000000_add_true_utc_dates/down.sql @@ -1,4 +1,7 @@ ALTER TABLE user_ai_prefs DROP COLUMN display_tz; +ALTER TABLE image_exif DROP COLUMN original_date_taken_tz_source; +ALTER TABLE image_exif DROP COLUMN original_camera_offset_minutes; +ALTER TABLE image_exif DROP COLUMN original_date_utc; ALTER TABLE image_exif DROP COLUMN date_taken_tz_source; ALTER TABLE image_exif DROP COLUMN camera_offset_minutes; ALTER TABLE image_exif DROP COLUMN date_utc; diff --git a/migrations/2026-09-24-000000_add_true_utc_dates/up.sql b/migrations/2026-09-24-000000_add_true_utc_dates/up.sql index 30662d7..69550aa 100644 --- a/migrations/2026-09-24-000000_add_true_utc_dates/up.sql +++ b/migrations/2026-09-24-000000_add_true_utc_dates/up.sql @@ -1,4 +1,4 @@ --- True-instant date contract (ADR-0001 / spec #113, ticket #114). +-- True-instant date contract (ADR-0001 / spec #113, tickets #114 + #115). -- -- image_exif gains the new-contract columns alongside the untouched legacy -- `date_taken`: @@ -10,10 +10,23 @@ -- date_taken_tz_source — why the offset is what it is: -- offset_tag | gps | assumed_server | utc_direct -- | manual. --- user_ai_prefs gains the DST-proof display zone (IANA name); the legacy --- tz_offset_minutes column stays frozen for rollback. +-- +-- Manual date edits (ticket #115) write the new-contract triple alongside +-- the legacy pair and must be revertible, so image_exif also snapshots the +-- pre-override new-contract columns next to the existing legacy snapshot +-- pair (original_date_taken / original_date_taken_source): +-- original_date_utc / original_camera_offset_minutes / +-- original_date_taken_tz_source. +-- +-- All columns are additive and nullable; population happens at runtime +-- (ingest + the per-tick backfill drains), so no backfill SQL is needed +-- here. user_ai_prefs gains the DST-proof display zone (IANA name); the +-- legacy tz_offset_minutes column stays frozen for rollback. ALTER TABLE image_exif ADD COLUMN date_utc BIGINT; ALTER TABLE image_exif ADD COLUMN camera_offset_minutes INTEGER; ALTER TABLE image_exif ADD COLUMN date_taken_tz_source TEXT; +ALTER TABLE image_exif ADD COLUMN original_date_utc BIGINT; +ALTER TABLE image_exif ADD COLUMN original_camera_offset_minutes INTEGER; +ALTER TABLE image_exif ADD COLUMN original_date_taken_tz_source TEXT; ALTER TABLE user_ai_prefs ADD COLUMN display_tz TEXT; diff --git a/migrations/2026-09-25-000000_manual_date_triple_snapshot/down.sql b/migrations/2026-09-25-000000_manual_date_triple_snapshot/down.sql deleted file mode 100644 index 13202cf..0000000 --- a/migrations/2026-09-25-000000_manual_date_triple_snapshot/down.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE image_exif DROP COLUMN original_date_utc; -ALTER TABLE image_exif DROP COLUMN original_camera_offset_minutes; -ALTER TABLE image_exif DROP COLUMN original_date_taken_tz_source; diff --git a/migrations/2026-09-25-000000_manual_date_triple_snapshot/up.sql b/migrations/2026-09-25-000000_manual_date_triple_snapshot/up.sql deleted file mode 100644 index 785393f..0000000 --- a/migrations/2026-09-25-000000_manual_date_triple_snapshot/up.sql +++ /dev/null @@ -1,13 +0,0 @@ --- Manual date-edit rework (ticket #115). --- --- POST /image/exif/date now writes the new-contract triple --- (date_utc, camera_offset_minutes, date_taken_tz_source = 'manual') --- alongside the legacy (date_taken, date_taken_source) pair. Reverting an --- override must restore the resolver's new-contract triple as well as the --- legacy pair, so image_exif snapshots the pre-override new-contract --- columns next to the existing legacy snapshot pair --- (original_date_taken / original_date_taken_source). - -ALTER TABLE image_exif ADD COLUMN original_date_utc BIGINT; -ALTER TABLE image_exif ADD COLUMN original_camera_offset_minutes INTEGER; -ALTER TABLE image_exif ADD COLUMN original_date_taken_tz_source TEXT;