release nouri 0.5.0 shopping rhythm pwa and reminders
This commit is contained in:
@@ -3,6 +3,9 @@ PRAGMA foreign_keys = ON;
|
||||
CREATE TABLE IF NOT EXISTS households (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
shopping_weekday INTEGER NOT NULL DEFAULT 5,
|
||||
shopping_prep_days INTEGER NOT NULL DEFAULT 1,
|
||||
shopping_reminder_time TEXT NOT NULL DEFAULT '18:00',
|
||||
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
@@ -28,6 +31,7 @@ CREATE TABLE IF NOT EXISTS household_categories (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
household_id INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
builder_key TEXT NOT NULL DEFAULT 'neutral',
|
||||
sort_order INTEGER NOT NULL DEFAULT 100,
|
||||
is_active INTEGER NOT NULL DEFAULT 1,
|
||||
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
@@ -35,6 +39,41 @@ CREATE TABLE IF NOT EXISTS household_categories (
|
||||
FOREIGN KEY (household_id) REFERENCES households(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS user_settings (
|
||||
user_id INTEGER PRIMARY KEY,
|
||||
reminders_enabled INTEGER NOT NULL DEFAULT 1,
|
||||
push_enabled INTEGER NOT NULL DEFAULT 0,
|
||||
notification_channel TEXT NOT NULL DEFAULT 'in_app',
|
||||
remind_before_shopping INTEGER NOT NULL DEFAULT 1,
|
||||
remind_on_shopping_day INTEGER NOT NULL DEFAULT 1,
|
||||
show_missing_for_upcoming_week INTEGER NOT NULL DEFAULT 1,
|
||||
show_planned_not_shopped INTEGER NOT NULL DEFAULT 1,
|
||||
remind_tomorrow_if_sparse INTEGER NOT NULL DEFAULT 1,
|
||||
remind_week_if_sparse INTEGER NOT NULL DEFAULT 1,
|
||||
suggest_home_for_today INTEGER NOT NULL DEFAULT 1,
|
||||
remind_small_snack INTEGER NOT NULL DEFAULT 0,
|
||||
remind_nuts INTEGER NOT NULL DEFAULT 0,
|
||||
show_meal_balancing INTEGER NOT NULL DEFAULT 1,
|
||||
suggest_templates INTEGER NOT NULL DEFAULT 1,
|
||||
suggest_patterns INTEGER NOT NULL DEFAULT 1,
|
||||
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS push_subscriptions (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
endpoint TEXT NOT NULL UNIQUE,
|
||||
p256dh TEXT NOT NULL,
|
||||
auth TEXT NOT NULL,
|
||||
user_agent TEXT,
|
||||
is_active INTEGER NOT NULL DEFAULT 1,
|
||||
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
last_test_at TEXT,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS dayparts (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
slug TEXT NOT NULL UNIQUE,
|
||||
@@ -106,6 +145,29 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_shopping_entries_open_item
|
||||
ON shopping_entries (item_id)
|
||||
WHERE is_checked = 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS shopping_needs (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
household_id INTEGER NOT NULL,
|
||||
owner_user_id INTEGER,
|
||||
visibility TEXT NOT NULL DEFAULT 'shared',
|
||||
item_id INTEGER NOT NULL,
|
||||
source_item_id INTEGER,
|
||||
needed_for_date TEXT NOT NULL,
|
||||
needed_for_daypart_id INTEGER,
|
||||
activation_date TEXT NOT NULL,
|
||||
is_activated INTEGER NOT NULL DEFAULT 0,
|
||||
activated_at TEXT,
|
||||
created_by INTEGER,
|
||||
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (item_id, source_item_id, needed_for_date, needed_for_daypart_id, visibility),
|
||||
FOREIGN KEY (household_id) REFERENCES households(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (owner_user_id) REFERENCES users(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (item_id) REFERENCES items(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (source_item_id) REFERENCES items(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (needed_for_daypart_id) REFERENCES dayparts(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS plan_entries (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
household_id INTEGER,
|
||||
@@ -218,6 +280,9 @@ 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_shopping_needs_household_activation
|
||||
ON shopping_needs (household_id, activation_date, is_activated);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_day_templates_household_visibility
|
||||
ON day_templates (household_id, visibility, name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user