release nouri 0.4.0 templates suggestions and mobile sheet
This commit is contained in:
+102
-1
@@ -24,6 +24,17 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_users_email_unique
|
||||
ON users (email)
|
||||
WHERE email IS NOT NULL AND email != '';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS household_categories (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
household_id INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
sort_order INTEGER NOT NULL DEFAULT 100,
|
||||
is_active INTEGER NOT NULL DEFAULT 1,
|
||||
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (household_id, name),
|
||||
FOREIGN KEY (household_id) REFERENCES households(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS dayparts (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
slug TEXT NOT NULL UNIQUE,
|
||||
@@ -35,6 +46,7 @@ CREATE TABLE IF NOT EXISTS items (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
household_id INTEGER,
|
||||
owner_user_id INTEGER,
|
||||
target_user_id INTEGER,
|
||||
visibility TEXT NOT NULL DEFAULT 'shared',
|
||||
kind TEXT NOT NULL CHECK (kind IN ('food', 'meal')),
|
||||
name TEXT NOT NULL,
|
||||
@@ -48,6 +60,7 @@ CREATE TABLE IF NOT EXISTS items (
|
||||
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (household_id) REFERENCES households(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (owner_user_id) REFERENCES users(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (target_user_id) REFERENCES users(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE SET NULL
|
||||
);
|
||||
@@ -76,6 +89,8 @@ CREATE TABLE IF NOT EXISTS shopping_entries (
|
||||
item_id INTEGER NOT NULL,
|
||||
added_by INTEGER,
|
||||
checked_by INTEGER,
|
||||
needed_for_date TEXT,
|
||||
needed_for_daypart_id INTEGER,
|
||||
is_checked INTEGER NOT NULL DEFAULT 0,
|
||||
added_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
checked_at TEXT,
|
||||
@@ -83,7 +98,8 @@ CREATE TABLE IF NOT EXISTS shopping_entries (
|
||||
FOREIGN KEY (owner_user_id) REFERENCES users(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (item_id) REFERENCES items(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (added_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (checked_by) REFERENCES users(id) ON DELETE SET NULL
|
||||
FOREIGN KEY (checked_by) REFERENCES users(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (needed_for_daypart_id) REFERENCES dayparts(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_shopping_entries_open_item
|
||||
@@ -108,12 +124,88 @@ CREATE TABLE IF NOT EXISTS plan_entries (
|
||||
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS day_templates (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
household_id INTEGER NOT NULL,
|
||||
owner_user_id INTEGER,
|
||||
visibility TEXT NOT NULL DEFAULT 'shared',
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
last_used_at TEXT,
|
||||
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (household_id) REFERENCES households(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (owner_user_id) REFERENCES users(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS day_template_entries (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
day_template_id INTEGER NOT NULL,
|
||||
daypart_id INTEGER NOT NULL,
|
||||
item_id INTEGER NOT NULL,
|
||||
sort_order INTEGER NOT NULL DEFAULT 100,
|
||||
FOREIGN KEY (day_template_id) REFERENCES day_templates(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (daypart_id) REFERENCES dayparts(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (item_id) REFERENCES items(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS week_templates (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
household_id INTEGER NOT NULL,
|
||||
owner_user_id INTEGER,
|
||||
visibility TEXT NOT NULL DEFAULT 'shared',
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
last_used_at TEXT,
|
||||
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (household_id) REFERENCES households(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (owner_user_id) REFERENCES users(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS week_template_days (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
week_template_id INTEGER NOT NULL,
|
||||
weekday_index INTEGER NOT NULL,
|
||||
day_template_id INTEGER NOT NULL,
|
||||
UNIQUE (week_template_id, weekday_index),
|
||||
FOREIGN KEY (week_template_id) REFERENCES week_templates(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (day_template_id) REFERENCES day_templates(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS item_sets (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
household_id INTEGER NOT NULL,
|
||||
owner_user_id INTEGER,
|
||||
visibility TEXT NOT NULL DEFAULT 'shared',
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
last_used_at TEXT,
|
||||
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (household_id) REFERENCES households(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (owner_user_id) REFERENCES users(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS item_set_items (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
item_set_id INTEGER NOT NULL,
|
||||
item_id INTEGER NOT NULL,
|
||||
sort_order INTEGER NOT NULL DEFAULT 100,
|
||||
UNIQUE (item_set_id, item_id),
|
||||
FOREIGN KEY (item_set_id) REFERENCES item_sets(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (item_id) REFERENCES items(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_items_kind_name
|
||||
ON items (kind, name);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_items_household_visibility
|
||||
ON items (household_id, visibility, availability_state);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_items_target_user
|
||||
ON items (target_user_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_item_dayparts_daypart_item
|
||||
ON item_dayparts (daypart_id, item_id);
|
||||
|
||||
@@ -125,3 +217,12 @@ ON plan_entries (household_id, visibility, plan_date);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_shopping_entries_household_visibility
|
||||
ON shopping_entries (household_id, visibility, is_checked);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_day_templates_household_visibility
|
||||
ON day_templates (household_id, visibility, name);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_week_templates_household_visibility
|
||||
ON week_templates (household_id, visibility, name);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_item_sets_household_visibility
|
||||
ON item_sets (household_id, visibility, name);
|
||||
|
||||
Reference in New Issue
Block a user