fix(db): drop 0.8 rebuild workarounds, enforce title
With sqlx 0.9 honouring `-- no-transaction`, 0007 loses its movie_releases_backup stash like 0014 did, and 0021 gains the CHECK (title <> '') that #153 abandoned because the 0.8 migrator could not run a rebuild with foreign keys off. The rebuild test now enters at migration 6 so the child links ride through all three rebuilds, and a new test proves the '' -> 'TBA' backfill and the rejection of new empty titles. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
-- no-transaction
|
||||
-- #73. movies.state used missing|grabbed|imported, predating arr-core's
|
||||
-- canonical MediaState vocabulary (missing|downloading|available) that
|
||||
-- series/episodes (0005) already follow.
|
||||
--
|
||||
-- SQLite can't ALTER a CHECK constraint, so this rebuilds the table -- which
|
||||
-- means dropping the old copy. `movie_releases` references it with
|
||||
-- ON DELETE CASCADE, so the drop would take its rows down too; stash them
|
||||
-- first and restore them once the new `movies` exists with the same ids.
|
||||
-- SQLite can't ALTER a CHECK constraint, so this rebuilds the table. It runs
|
||||
-- outside a transaction (#155) so `PRAGMA foreign_keys = OFF` takes effect
|
||||
-- and dropping the old `movies` does not cascade into `movie_releases`.
|
||||
|
||||
CREATE TABLE movie_releases_backup AS SELECT * FROM movie_releases;
|
||||
PRAGMA foreign_keys = OFF;
|
||||
|
||||
CREATE TABLE movies_new (
|
||||
id INTEGER PRIMARY KEY,
|
||||
@@ -68,6 +68,4 @@ BEGIN
|
||||
SELECT RAISE(ABORT, 'movies require a movie root');
|
||||
END;
|
||||
|
||||
INSERT INTO movie_releases SELECT * FROM movie_releases_backup;
|
||||
|
||||
DROP TABLE movie_releases_backup;
|
||||
PRAGMA foreign_keys = ON;
|
||||
|
||||
Reference in New Issue
Block a user