mirror of
https://github.com/Dictionarry-Hub/schema.git
synced 2026-05-03 06:14:17 +02:00
fix: test_releases FK stability issue
This commit is contained in:
+7
-1
@@ -54,4 +54,10 @@ All schema changes will be documented in this file.
|
|||||||
- Add quality profile testing tables
|
- Add quality profile testing tables
|
||||||
- test_entities: stores movies/series from TMDB for testing quality profiles
|
- test_entities: stores movies/series from TMDB for testing quality profiles
|
||||||
- test_releases: stores sample releases attached to test entities
|
- test_releases: stores sample releases attached to test entities
|
||||||
- Supports languages, indexers, and flags as JSON arrays for release metadata
|
- Supports languages, indexers, and flags as JSON arrays for release metadata
|
||||||
|
|
||||||
|
## 19-1-26
|
||||||
|
- Fix test_releases FK stability issue
|
||||||
|
- Changed from test_entity_id (auto-generated) to composite FK (entity_type, entity_tmdb_id)
|
||||||
|
- Ensures releases remain correctly linked after database recompile from ops
|
||||||
|
- Updated index to use composite key
|
||||||
+5
-3
@@ -416,9 +416,11 @@ CREATE TABLE test_entities (
|
|||||||
);
|
);
|
||||||
|
|
||||||
-- Test releases attached to entities
|
-- Test releases attached to entities
|
||||||
|
-- Uses composite FK (entity_type, entity_tmdb_id) for stable references across recompiles
|
||||||
CREATE TABLE test_releases (
|
CREATE TABLE test_releases (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
test_entity_id INTEGER NOT NULL,
|
entity_type TEXT NOT NULL CHECK (entity_type IN ('movie', 'series')),
|
||||||
|
entity_tmdb_id INTEGER NOT NULL,
|
||||||
title TEXT NOT NULL,
|
title TEXT NOT NULL,
|
||||||
size_bytes INTEGER,
|
size_bytes INTEGER,
|
||||||
languages TEXT NOT NULL DEFAULT '[]',
|
languages TEXT NOT NULL DEFAULT '[]',
|
||||||
@@ -426,10 +428,10 @@ CREATE TABLE test_releases (
|
|||||||
flags TEXT NOT NULL DEFAULT '[]',
|
flags TEXT NOT NULL DEFAULT '[]',
|
||||||
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
FOREIGN KEY (test_entity_id) REFERENCES test_entities(id) ON DELETE CASCADE
|
FOREIGN KEY (entity_type, entity_tmdb_id) REFERENCES test_entities(type, tmdb_id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX idx_test_releases_entity ON test_releases(test_entity_id);
|
CREATE INDEX idx_test_releases_entity ON test_releases(entity_type, entity_tmdb_id);
|
||||||
|
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
-- INDEXES AND CONSTRAINTS
|
-- INDEXES AND CONSTRAINTS
|
||||||
|
|||||||
Reference in New Issue
Block a user