From 45c758bb534e33c150154a3b6964a4cabfe18a8a Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Sun, 5 Apr 2026 22:24:06 -0700 Subject: [PATCH] revert: remove ADD COLUMN IF NOT EXISTS (not a SQLite feature) SQLite does not support ADD COLUMN IF NOT EXISTS regardless of version. The idempotency fix lives in cf-core's migration runner instead. --- app/db/migrations/004_staging_tracking.sql | 10 ++++------ app/db/migrations/005_listing_category.sql | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/db/migrations/004_staging_tracking.sql b/app/db/migrations/004_staging_tracking.sql index 9a3aa0d..7656690 100644 --- a/app/db/migrations/004_staging_tracking.sql +++ b/app/db/migrations/004_staging_tracking.sql @@ -1,12 +1,10 @@ -- Staging DB: persistent listing tracking across searches. -- Adds temporal metadata to listings so we can detect stale/repriced/recurring items. --- IF NOT EXISTS (SQLite 3.35+, Python 3.11 ships 3.39+) makes this safe to re-run --- in any state: fresh install, partial-failure recovery, or already-applied. -ALTER TABLE listings ADD COLUMN IF NOT EXISTS first_seen_at TEXT; -ALTER TABLE listings ADD COLUMN IF NOT EXISTS last_seen_at TEXT; -ALTER TABLE listings ADD COLUMN IF NOT EXISTS times_seen INTEGER NOT NULL DEFAULT 1; -ALTER TABLE listings ADD COLUMN IF NOT EXISTS price_at_first_seen REAL; +ALTER TABLE listings ADD COLUMN first_seen_at TEXT; +ALTER TABLE listings ADD COLUMN last_seen_at TEXT; +ALTER TABLE listings ADD COLUMN times_seen INTEGER NOT NULL DEFAULT 1; +ALTER TABLE listings ADD COLUMN price_at_first_seen REAL; -- Backfill existing rows so columns are non-null where we have data UPDATE listings SET diff --git a/app/db/migrations/005_listing_category.sql b/app/db/migrations/005_listing_category.sql index fc5e1cc..2d0ca4c 100644 --- a/app/db/migrations/005_listing_category.sql +++ b/app/db/migrations/005_listing_category.sql @@ -1,3 +1,3 @@ -- Add per-listing category name, extracted from eBay API response. -- Used to derive seller category_history_json without _ssn scraping. -ALTER TABLE listings ADD COLUMN IF NOT EXISTS category_name TEXT; +ALTER TABLE listings ADD COLUMN category_name TEXT;