From 1b2b24356edae834eba435393a02af297e8df203 Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Wed, 5 Nov 2025 08:37:31 +1030 Subject: [PATCH] feat: enforce enabled / disabled in qpq's --- ops/0.schema.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ops/0.schema.sql b/ops/0.schema.sql index 14e5853..da21d46 100644 --- a/ops/0.schema.sql +++ b/ops/0.schema.sql @@ -148,12 +148,15 @@ CREATE TABLE quality_group_members ( -- Define the quality list for a profile (ordered by position) -- 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 ( id INTEGER PRIMARY KEY AUTOINCREMENT, quality_profile_id INTEGER NOT NULL, quality_id INTEGER, -- References a single quality quality_group_id INTEGER, -- OR references a quality group 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 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, @@ -253,6 +256,6 @@ CREATE TABLE condition_years ( -- ============================================================================ -- Ensure only one quality item per profile can be marked as upgrade_until -CREATE UNIQUE INDEX idx_one_upgrade_until_per_profile -ON quality_profile_qualities(quality_profile_id) -WHERE upgrade_until = 1; \ No newline at end of file +CREATE UNIQUE INDEX idx_one_upgrade_until_per_profile +ON quality_profile_qualities(quality_profile_id) +WHERE upgrade_until = 1;