Compare commits

..
2 Commits
Author SHA1 Message Date
John O'Keefe 4f913da0b1 chore(db): schema.go searches three levels up — replaces the tests-dir symlink
Release / build-and-push (push) Successful in 3m8s
Host-side test runs use CWD=cmd/server/tests, three levels below the repo
root; the location search only went up two, so it never found
database/schema/schema.sql from there and init() fatal-exited. That gap
was being papered over by an untracked local symlink
(cmd/server/tests/database -> ../../../database) hidden behind a bare
`database` line in .git/info/exclude — which also broke `git add` under
database/. Fix the search list instead and drop the filesystem trick:
no symlink to commit, no exclude hack, works on any platform.

Verified: contract pins green from cmd/server/tests with no symlink
present (init resolves via the new entry); parse test green.
2026-10-17 22:51:55 -04:00
John O'Keefe 0799cca3e6 fix(schema): ship the two Batch-A upgrade ALTERs that 1.15.0 missed
audio_metadata (media_items) and audio_offset_seconds (reading_progress)
were declared only inside their CREATE TABLE blocks — fresh installs got
them, upgraded installs never did, because columns reach existing
databases only via the idempotent ALTER block that schema.sql re-runs on
every boot. On prod (v1.15.0) this 42703'd every media-existence check
and the archive pass (1817/1817 scan errors), and every progress save,
since the shared progress upsert names audio_offset_seconds.

Both ALTERs match the declared shapes exactly (nullable JSONB; INTEGER
CHECK (audio_offset_seconds >= 0)); idempotent, applied on every boot.

Verified against a scratch database built to the v1.14.0 shape: overlay
the patched schema -> both columns created; re-run (every boot) skips
cleanly; probes resolve reading_progress.audio_offset_seconds integer
and media_items.audio_metadata jsonb. Parse test and a real container
boot (38 tables, 6 functions verified) green.
2026-10-17 22:46:01 -04:00
2 changed files with 12 additions and 0 deletions

No files matched your search

+9
View File
@@ -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 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 narrators_search TEXT[] NOT NULL DEFAULT '{}';
ALTER TABLE media_items ADD COLUMN IF NOT EXISTS abridged BOOLEAN NOT NULL DEFAULT FALSE; 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 -- Per-field user-override tracking (idempotent backfill for existing
-- installs; the column is also declared in the media_items table -- 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 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 media_ratings table
CREATE TABLE IF NOT EXISTS media_ratings ( CREATE TABLE IF NOT EXISTS media_ratings (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(), id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
+3
View File
@@ -25,6 +25,9 @@ func init() {
"/app/database/schema/schema.sql", "/app/database/schema/schema.sql",
"../database/schema/schema.sql", "../database/schema/schema.sql",
"../../database/schema/schema.sql", "../../database/schema/schema.sql",
// Integration tests run with CWD=cmd/server/tests, three levels
// below the repo root — two up only reaches cmd/.
"../../../database/schema/schema.sql",
} }
var content []byte var content []byte