From e5f90f4474cb96a78080395980283e4b2ce40214 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 15 Feb 2026 22:24:32 +0100 Subject: feat(treewide): Add recipes and user handling --- .../rocie-server/src/storage/migrate/sql/0->1.sql | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'crates/rocie-server/src/storage/migrate/sql') diff --git a/crates/rocie-server/src/storage/migrate/sql/0->1.sql b/crates/rocie-server/src/storage/migrate/sql/0->1.sql index e3dd879..ba44c68 100644 --- a/crates/rocie-server/src/storage/migrate/sql/0->1.sql +++ b/crates/rocie-server/src/storage/migrate/sql/0->1.sql @@ -14,17 +14,29 @@ CREATE TABLE version ( valid_to INTEGER UNIQUE CHECK (valid_to > valid_from) ) STRICT; --- Encodes the tree structure of the products. --- A parent cannot be a product, but can have parents on it's own. +-- Encodes the tree structure of the product parents. +-- A product parent cannot be a product, but can have parents on it's own. -- TODO: Fix the possibility for cyclic parent-ship entries <2025-09-05> -CREATE TABLE parents ( +CREATE TABLE product_parents ( id TEXT UNIQUE NOT NULL PRIMARY KEY, parent TEXT DEFAULT NULL CHECK ( id IS NOT parent ), name TEXT UNIQUE NOT NULL, description TEXT, - FOREIGN KEY(parent) REFERENCES parents(id) + FOREIGN KEY(parent) REFERENCES product_parents(id) +) STRICT; + +-- Encodes the tree structure of the recipe parents. +-- TODO: Fix the possibility for cyclic parent-ship entries <2025-09-05> +CREATE TABLE recipe_parents ( + id TEXT UNIQUE NOT NULL PRIMARY KEY, + parent TEXT DEFAULT NULL CHECK ( + id IS NOT parent + ), + name TEXT UNIQUE NOT NULL, + description TEXT, + FOREIGN KEY(parent) REFERENCES recipe_parents(id) ) STRICT; -- Stores the registered users. @@ -71,7 +83,7 @@ CREATE TABLE products ( description TEXT, parent TEXT DEFAULT NULL, unit_property TEXT NOT NULL, - FOREIGN KEY(parent) REFERENCES parents(id), + FOREIGN KEY(parent) REFERENCES product_parents(id), FOREIGN KEY(unit_property) REFERENCES unit_properties(id) ) STRICT; @@ -123,8 +135,10 @@ CREATE TABLE unit_properties ( CREATE TABLE recipies ( id TEXT UNIQUE NOT NULL PRIMARY KEY, - path TEXT UNIQUE NOT NULL, - content TEXT NOT NULL + name TEXT UNIQUE NOT NULL, + parent TEXT, + content TEXT NOT NULL, + FOREIGN KEY(parent) REFERENCES recipe_parents(id) ) STRICT; -- Encodes unit conversions: -- cgit 1.4.1