3082568171
PRs #97 and #98 each added a migration numbered 0011; merged together sqlx hits UNIQUE on _sqlx_migrations.version. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
26 lines
1.2 KiB
SQL
26 lines
1.2 KiB
SQL
-- #86: a grab whose torrent Transmission no longer reports (manual removal,
|
|
-- not a policy failure) gets its own state. Distinct from 'failed' so it
|
|
-- does not feed the needs_decision attention queue (attention.rs), which
|
|
-- counts 'failed' as a hard-fail signal. SQLite cannot alter a CHECK, so the
|
|
-- table is rebuilt (see 0010).
|
|
CREATE TABLE grabs_new (
|
|
id INTEGER PRIMARY KEY,
|
|
release_id INTEGER NOT NULL REFERENCES releases (id),
|
|
target_kind TEXT NOT NULL CHECK (target_kind IN ('movie', 'episode', 'season')),
|
|
target_id INTEGER NOT NULL,
|
|
infohash TEXT NOT NULL UNIQUE,
|
|
state TEXT NOT NULL DEFAULT 'sent'
|
|
CHECK (state IN ('sent', 'downloaded', 'imported', 'failed', 'vanished')),
|
|
grabbed_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
|
|
imported_at TEXT
|
|
) STRICT;
|
|
|
|
INSERT INTO grabs_new (id, release_id, target_kind, target_id, infohash, state, grabbed_at, imported_at)
|
|
SELECT id, release_id, target_kind, target_id, infohash, state, grabbed_at, imported_at FROM grabs;
|
|
|
|
DROP TABLE grabs;
|
|
ALTER TABLE grabs_new RENAME TO grabs;
|
|
|
|
CREATE INDEX grabs_state ON grabs (state);
|
|
CREATE INDEX grabs_target ON grabs (target_kind, target_id);
|