fix(db): bump sqlx to 0.9, honour no-transaction
sqlx-sqlite 0.8 ignored Migration.no_tx and wrapped every migration in a transaction, where PRAGMA foreign_keys = OFF is a no-op — so any table rebuild cascade-deleted children. 0.9 honours `-- no-transaction`, so 0014 drops its movie_releases_backup / episode_releases_backup workaround and runs the plain rebuild recipe with foreign keys off. A migration test rebuilds both parents from a pre-0014 database and asserts the child link rows survive. Closes #155 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
-- no-transaction
|
||||
-- #108: a vanished torrent must not re-grab. Overrides #86, which reopened
|
||||
-- the gap (state = 'missing', wanted untouched) so the next tick re-grabbed
|
||||
-- the same release. Adds 'parked' so the daemon can clear `wanted` and mark
|
||||
-- the title honestly instead — distinct from 'missing' (an open gap) and
|
||||
-- 'available' (satisfied). SQLite cannot alter a CHECK, so both tables are
|
||||
-- rebuilt (see 0007).
|
||||
--
|
||||
-- #155: runs outside a transaction so `PRAGMA foreign_keys = OFF` takes
|
||||
-- effect and dropping the old tables does not cascade into their children.
|
||||
|
||||
CREATE TABLE movie_releases_backup AS SELECT * FROM movie_releases;
|
||||
PRAGMA foreign_keys = OFF;
|
||||
|
||||
CREATE TABLE movies_new (
|
||||
id INTEGER PRIMARY KEY,
|
||||
@@ -63,11 +67,6 @@ BEGIN
|
||||
SELECT RAISE(ABORT, 'movies require a movie root');
|
||||
END;
|
||||
|
||||
INSERT INTO movie_releases SELECT * FROM movie_releases_backup;
|
||||
DROP TABLE movie_releases_backup;
|
||||
|
||||
CREATE TABLE episode_releases_backup AS SELECT * FROM episode_releases;
|
||||
|
||||
CREATE TABLE episodes_new (
|
||||
id INTEGER PRIMARY KEY,
|
||||
season_id INTEGER NOT NULL REFERENCES seasons (id) ON DELETE CASCADE,
|
||||
@@ -102,5 +101,4 @@ CREATE INDEX episodes_pending_search
|
||||
|
||||
CREATE INDEX episodes_state ON episodes (state);
|
||||
|
||||
INSERT INTO episode_releases SELECT * FROM episode_releases_backup;
|
||||
DROP TABLE episode_releases_backup;
|
||||
PRAGMA foreign_keys = ON;
|
||||
|
||||
Reference in New Issue
Block a user