mirror of
https://github.com/Dictionarry-Hub/schema.git
synced 2026-05-03 06:14:17 +02:00
feat: enforce enabled / disabled in qpq's
This commit is contained in:
+6
-3
@@ -148,12 +148,15 @@ CREATE TABLE quality_group_members (
|
|||||||
|
|
||||||
-- Define the quality list for a profile (ordered by position)
|
-- Define the quality list for a profile (ordered by position)
|
||||||
-- Each item references either a single quality OR a quality group (never both)
|
-- Each item references either a single quality OR a quality group (never both)
|
||||||
|
-- Every quality must be represented (either directly or in a group)
|
||||||
|
-- The enabled flag controls whether the quality/group is active
|
||||||
CREATE TABLE quality_profile_qualities (
|
CREATE TABLE quality_profile_qualities (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
quality_profile_id INTEGER NOT NULL,
|
quality_profile_id INTEGER NOT NULL,
|
||||||
quality_id INTEGER, -- References a single quality
|
quality_id INTEGER, -- References a single quality
|
||||||
quality_group_id INTEGER, -- OR references a quality group
|
quality_group_id INTEGER, -- OR references a quality group
|
||||||
position INTEGER NOT NULL, -- Display order in the profile
|
position INTEGER NOT NULL, -- Display order in the profile
|
||||||
|
enabled INTEGER NOT NULL DEFAULT 1, -- Whether this quality/group is enabled
|
||||||
upgrade_until INTEGER NOT NULL DEFAULT 0, -- Stop upgrading at this quality
|
upgrade_until INTEGER NOT NULL DEFAULT 0, -- Stop upgrading at this quality
|
||||||
CHECK ((quality_id IS NOT NULL AND quality_group_id IS NULL) OR (quality_id IS NULL AND quality_group_id IS NOT NULL)),
|
CHECK ((quality_id IS NOT NULL AND quality_group_id IS NULL) OR (quality_id IS NULL AND quality_group_id IS NOT NULL)),
|
||||||
FOREIGN KEY (quality_profile_id) REFERENCES quality_profiles(id) ON DELETE CASCADE,
|
FOREIGN KEY (quality_profile_id) REFERENCES quality_profiles(id) ON DELETE CASCADE,
|
||||||
@@ -253,6 +256,6 @@ CREATE TABLE condition_years (
|
|||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
|
|
||||||
-- Ensure only one quality item per profile can be marked as upgrade_until
|
-- Ensure only one quality item per profile can be marked as upgrade_until
|
||||||
CREATE UNIQUE INDEX idx_one_upgrade_until_per_profile
|
CREATE UNIQUE INDEX idx_one_upgrade_until_per_profile
|
||||||
ON quality_profile_qualities(quality_profile_id)
|
ON quality_profile_qualities(quality_profile_id)
|
||||||
WHERE upgrade_until = 1;
|
WHERE upgrade_until = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user