diff --git a/database/schema/schema.sql b/database/schema/schema.sql index e9ab2aec..9385dd8c 100644 --- a/database/schema/schema.sql +++ b/database/schema/schema.sql @@ -263,6 +263,10 @@ ALTER TABLE media_items ADD COLUMN IF NOT EXISTS contributors_search TEXT[]; ALTER TABLE media_items ADD COLUMN IF NOT EXISTS narrators TEXT[] NOT NULL DEFAULT '{}'; ALTER TABLE media_items ADD COLUMN IF NOT EXISTS narrators_search TEXT[] NOT NULL DEFAULT '{}'; ALTER TABLE media_items ADD COLUMN IF NOT EXISTS abridged BOOLEAN NOT NULL DEFAULT FALSE; +-- audio_metadata is declared in the CREATE TABLE above, which only fresh +-- installs ever see — this ALTER is the upgrade path for pre-A2 installs +-- (its absence 42703'd every scan and archive pass on upgraded deployments). +ALTER TABLE media_items ADD COLUMN IF NOT EXISTS audio_metadata JSONB; -- Per-field user-override tracking (idempotent backfill for existing -- installs; the column is also declared in the media_items table @@ -371,6 +375,11 @@ CREATE TABLE IF NOT EXISTS reading_progress ( conflict_resolved BOOLEAN DEFAULT TRUE ); +-- audio_offset_seconds upgrade path: declared in the CREATE TABLE above +-- (Batch A) with no ALTER, so pre-A installs lacked the column and every +-- progress save — the shared upsert names it — failed with SQLSTATE 42703. +ALTER TABLE reading_progress ADD COLUMN IF NOT EXISTS audio_offset_seconds INTEGER CHECK (audio_offset_seconds >= 0); + -- Create media_ratings table CREATE TABLE IF NOT EXISTS media_ratings ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(),