Farb palette

This commit is contained in:
2025-12-04 16:06:58 +01:00
parent 0554fdda01
commit aa9bd3f0b6
50 changed files with 3971 additions and 899 deletions

View File

@@ -2,7 +2,7 @@
* Database schema definitions and migration scripts
*/
export const SCHEMA_VERSION = 7;
export const SCHEMA_VERSION = 8;
export const CREATE_TABLES = `
-- Projects table
@@ -72,9 +72,33 @@ export const CREATE_TABLES = `
user_id TEXT PRIMARY KEY NOT NULL,
unit_system TEXT NOT NULL CHECK(unit_system IN ('imperial', 'metric')),
temp_unit TEXT NOT NULL CHECK(temp_unit IN ('F', 'C')),
weight_unit TEXT NOT NULL DEFAULT 'lb' CHECK(weight_unit IN ('lb', 'oz', 'kg', 'g')),
analytics_opt_in INTEGER NOT NULL DEFAULT 0
);
-- User lists (shopping and wish lists)
CREATE TABLE IF NOT EXISTS user_lists (
id TEXT PRIMARY KEY NOT NULL,
user_id TEXT NOT NULL,
type TEXT NOT NULL CHECK(type IN ('shopping', 'wish')),
item TEXT NOT NULL,
notes TEXT,
is_completed INTEGER NOT NULL DEFAULT 0,
created_at TEXT NOT NULL,
FOREIGN KEY (user_id) REFERENCES settings(user_id)
);
-- Forming step fields (production phase)
CREATE TABLE IF NOT EXISTS forming_fields (
step_id TEXT PRIMARY KEY NOT NULL,
clay_body TEXT,
clay_weight_value REAL,
clay_weight_unit TEXT CHECK(clay_weight_unit IN ('lb', 'oz', 'kg', 'g')),
production_method TEXT CHECK(production_method IN ('wheel', 'handbuilding', 'casting', 'other')),
dimensions TEXT,
FOREIGN KEY (step_id) REFERENCES steps(id) ON DELETE CASCADE
);
-- News/Tips cache (per user)
CREATE TABLE IF NOT EXISTS news_items (
id TEXT PRIMARY KEY NOT NULL,
@@ -98,14 +122,18 @@ export const CREATE_TABLES = `
CREATE INDEX IF NOT EXISTS idx_glazes_is_custom ON glazes(is_custom);
CREATE INDEX IF NOT EXISTS idx_news_user_id ON news_items(user_id);
CREATE INDEX IF NOT EXISTS idx_news_published_at ON news_items(published_at DESC);
CREATE INDEX IF NOT EXISTS idx_user_lists_user_id ON user_lists(user_id);
CREATE INDEX IF NOT EXISTS idx_user_lists_type ON user_lists(type);
`;
export const DROP_ALL_TABLES = `
DROP TABLE IF EXISTS firing_fields;
DROP TABLE IF EXISTS glazing_fields;
DROP TABLE IF EXISTS forming_fields;
DROP TABLE IF EXISTS steps;
DROP TABLE IF EXISTS projects;
DROP TABLE IF EXISTS glazes;
DROP TABLE IF EXISTS settings;
DROP TABLE IF EXISTS news_items;
DROP TABLE IF EXISTS user_lists;
`;