fix(indexbuild): repair the one database a squash cannot reach
Build & publish Arch package / arch-package (push) Successful in 2m34s
CI / check (push) Successful in 2m36s
Search index maintenance / maintain-index (push) Successful in 6s
CI / e2e (push) Successful in 5m32s

The index job's /cache volume is a real YJ_HOME that outlives every
run, so plan 013's reshaped audio_files met a database still in the
old shape: `CREATE INDEX ... album_id` against a table without that
column, on every launch. "Delete and rescan" is the squash's answer
and is free everywhere except here, where half the file is the catalog
and deleting it costs ~205GB of downloading.

indexbuild now drops every table datamap does not classify as Cache
before the schema is applied. Nothing scans, plays or authors in that
database, so its non-catalog half is empty by construction and a shape
the schema stopped describing is pure liability; the catalog is never
touched.

TestRetireLibraryTables reproduces the failure symptom-first: build
the real schema, put audio_files back the way the volume had it,
assert the open fails, then assert the repair makes it open with the
catalog row still there.
This commit is contained in:
2026-08-16 15:09:09 -04:00
parent 18aba34c08
commit 66182f82cd
4 changed files with 289 additions and 0 deletions
+8
View File
@@ -32,6 +32,7 @@
package main
import (
"context"
"errors"
"flag"
"fmt"
@@ -127,6 +128,13 @@ func run(o opts) error {
return fmt.Errorf("resolve data dir: %w", err)
}
// Before the schema is applied, not after: applying it over a table
// whose shape has since changed is what fails, and this database's
// non-catalog half is disposable. See retireLibraryTables.
if err := retireLibraryTables(context.Background(), logger); err != nil {
return fmt.Errorf("retire stale tables: %w", err)
}
db, err := database.NewDB(logger)
if err != nil {
return fmt.Errorf("open database: %w", err)