Doc
This commit is contained in:
parent
7230ca607d
commit
8dcaac35b7
2 changed files with 301 additions and 298 deletions
128
README.md
128
README.md
|
|
@ -1,63 +1,65 @@
|
||||||
# Technical
|
# Technical
|
||||||
|
|
||||||
## Backend
|
## Backend
|
||||||
|
|
||||||
### Launch Axum
|
### Launch Axum
|
||||||
|
|
||||||
In directory '/backend' type:
|
In directory '/backend' type:
|
||||||
$> cargo run
|
$> cargo run
|
||||||
|
|
||||||
Then browse http://127.0.0.1:8082 (You need to compile the wasm file first, see section 'Frontend')
|
Then browse http://127.0.0.1:8082 (You need to compile the wasm file first, see section 'Frontend')
|
||||||
|
|
||||||
At first launch the configuration file '/backend/conf.ron' is created. It contains the port the server will listen to and information about the SMTP server which will be used to send email when a user sign up or change its password.
|
At first launch the configuration file '/backend/conf.ron' is created. It contains the port the server will listen to and information about the SMTP server which will be used to send email when a user sign up or change its password.
|
||||||
|
|
||||||
### Autoreload
|
### Autoreload
|
||||||
|
|
||||||
First install cargo watch:
|
First install cargo watch:
|
||||||
$> cargo install cargo-watch
|
$> cargo install cargo-watch
|
||||||
|
|
||||||
In directory '/backend' type:
|
In directory '/backend' type:
|
||||||
$> cargo watch -x run
|
$> cargo watch -x run
|
||||||
|
|
||||||
|
|
||||||
## Frontend
|
## Frontend
|
||||||
|
|
||||||
### Tools needed
|
### Tools needed
|
||||||
|
|
||||||
nushell: https://www.nushell.sh/
|
nushell: https://www.nushell.sh/
|
||||||
trunk: https://trunkrs.dev
|
trunk: https://trunkrs.dev
|
||||||
|
|
||||||
### Compilation
|
### Compilation
|
||||||
|
|
||||||
In directory '/frontend' type:
|
In directory '/frontend' type:
|
||||||
$> nu deploy.nu
|
$> nu deploy.nu
|
||||||
|
|
||||||
It will create the '/frontend/pkg' directory and copy the wasm file into '/backend/static'.
|
It will create the '/frontend/pkg' directory and copy the wasm file into '/backend/static'.
|
||||||
You can now refresh your browser to reload the wasm file.
|
You can now refresh your browser to reload the wasm file.
|
||||||
|
|
||||||
# How-to
|
# How-to
|
||||||
|
|
||||||
## How to install service on a Linux server
|
## How to install service on a Linux server
|
||||||
|
|
||||||
As root:
|
As root:
|
||||||
|
|
||||||
1. Copy '/doc/recipes.service' to '/lib/systemd/system/'
|
1. Copy '/doc/recipes.service' to '/lib/systemd/system/'
|
||||||
2. Enabled it: #> systemctl enable recipes
|
2. Enabled it: #> systemctl enable recipes
|
||||||
3. Launch it: #> systemctl start recipes
|
3. Launch it: #> systemctl start recipes
|
||||||
|
|
||||||
## Cross compile for Raspberry PI on Windows
|
## Cross compile for Raspberry PI on Windows
|
||||||
|
|
||||||
* $> https://gnutoolchains.com/raspberry/
|
* $> https://gnutoolchains.com/raspberry/
|
||||||
* https://gnutoolchains.com/raspberry64/
|
* https://gnutoolchains.com/raspberry64/
|
||||||
|
|
||||||
# Useful URLs
|
# Useful URLs
|
||||||
|
|
||||||
* Rust patterns : https://github.com/rust-unofficial/patterns
|
* Rust patterns: https://github.com/rust-unofficial/patterns
|
||||||
* Rust cheat Sheet: https://cheats.rs/
|
* Rust cheat Sheet: https://cheats.rs/
|
||||||
|
* HTML Validation Service: https://validator.w3.org/
|
||||||
|
* Site analysis: https://pagespeed.web.dev/
|
||||||
# Useful tools
|
* Open-Source UI: https://uiverse.io/
|
||||||
|
|
||||||
Benchmarking: https://crates.io/crates/oha
|
# Useful tools
|
||||||
HTTP API tool: https://www.usebruno.com/
|
|
||||||
GUI Database client: https://dbeaver.io/
|
HTTP benchmarking and stress tool: https://crates.io/crates/oha
|
||||||
|
HTTP API tool: https://www.usebruno.com/
|
||||||
|
GUI Database client: https://dbeaver.io/
|
||||||
|
|
|
||||||
|
|
@ -1,235 +1,236 @@
|
||||||
-- Datetimes are stored as 'ISO 8601' text format.
|
-- Datetimes are stored as 'ISO 8601' text format.
|
||||||
-- For example: '2025-01-07T10:41:05.697884837+00:00'.
|
-- For example: '2025-01-07T10:41:05.697884837+00:00'.
|
||||||
|
|
||||||
-- Version 1 is the initial structure.
|
-- Version 1 is the initial structure.
|
||||||
CREATE TABLE [Version] (
|
CREATE TABLE [Version] (
|
||||||
[id] INTEGER PRIMARY KEY,
|
[id] INTEGER PRIMARY KEY,
|
||||||
[version] INTEGER NOT NULL UNIQUE,
|
[version] INTEGER NOT NULL UNIQUE,
|
||||||
[datetime] TEXT
|
[datetime] TEXT
|
||||||
) STRICT;
|
) STRICT;
|
||||||
|
|
||||||
CREATE TABLE [User] (
|
CREATE TABLE [User] (
|
||||||
[id] INTEGER PRIMARY KEY,
|
[id] INTEGER PRIMARY KEY,
|
||||||
|
|
||||||
[email] TEXT NOT NULL,
|
[email] TEXT NOT NULL,
|
||||||
[name] TEXT NOT NULL DEFAULT '',
|
[name] TEXT NOT NULL DEFAULT '',
|
||||||
[creation_datetime] TEXT NOT NULL,
|
[creation_datetime] TEXT NOT NULL,
|
||||||
|
|
||||||
[default_servings] INTEGER DEFAULT 4,
|
[default_servings] INTEGER DEFAULT 4,
|
||||||
[lang] TEXT NOT NULL DEFAULT 'en',
|
[lang] TEXT NOT NULL DEFAULT 'en',
|
||||||
|
|
||||||
[password] TEXT NOT NULL, -- argon2(password_plain, salt).
|
[password] TEXT NOT NULL, -- argon2(password_plain, salt).
|
||||||
|
|
||||||
[validation_token_datetime] TEXT NOT NULL, -- Updated when the validation email is sent.
|
[validation_token_datetime] TEXT NOT NULL, -- Updated when the validation email is sent.
|
||||||
[validation_token] TEXT, -- If not null then the user has not validated his account yet.
|
[validation_token] TEXT, -- If not null then the user has not validated his account yet.
|
||||||
|
|
||||||
[password_reset_token] TEXT, -- If not null then the user can reset its password.
|
[password_reset_token] TEXT, -- If not null then the user can reset its password.
|
||||||
-- The time when the reset token has been created.
|
-- The time when the reset token has been created.
|
||||||
-- Password can only be reset during a certain duration after this time.
|
-- Password can only be reset during a certain duration after this time.
|
||||||
[password_reset_datetime] TEXT,
|
[password_reset_datetime] TEXT,
|
||||||
|
|
||||||
[is_admin] INTEGER NOT NULL DEFAULT FALSE
|
[is_admin] INTEGER NOT NULL DEFAULT FALSE
|
||||||
) STRICT;
|
) STRICT;
|
||||||
|
|
||||||
CREATE INDEX [validation_token_index] ON [User]([validation_token]);
|
CREATE INDEX [validation_token_index] ON [User]([validation_token]);
|
||||||
CREATE UNIQUE INDEX [User_email_index] ON [User]([email]);
|
CREATE UNIQUE INDEX [User_email_index] ON [User]([email]);
|
||||||
|
|
||||||
CREATE TABLE [UserLoginToken] (
|
CREATE TABLE [UserLoginToken] (
|
||||||
[id] INTEGER PRIMARY KEY,
|
[id] INTEGER PRIMARY KEY,
|
||||||
[user_id] INTEGER NOT NULL,
|
[user_id] INTEGER NOT NULL,
|
||||||
[last_login_datetime] TEXT,
|
[last_login_datetime] TEXT,
|
||||||
|
|
||||||
-- 24 alphanumeric character token.
|
-- 24 alphanumeric character token.
|
||||||
-- Can be stored in a cookie to be able to authenticate without a password.
|
-- Can be stored in a cookie to be able to authenticate without a password.
|
||||||
[token] TEXT NOT NULL,
|
[token] TEXT NOT NULL,
|
||||||
|
|
||||||
[ip] TEXT, -- Can be ipv4 or ipv6
|
[ip] TEXT, -- Can be ipv4 or ipv6
|
||||||
[user_agent] TEXT,
|
[user_agent] TEXT,
|
||||||
|
|
||||||
FOREIGN KEY([user_id]) REFERENCES [User]([id]) ON DELETE CASCADE
|
FOREIGN KEY([user_id]) REFERENCES [User]([id]) ON DELETE CASCADE
|
||||||
) STRICT;
|
) STRICT;
|
||||||
|
|
||||||
CREATE INDEX [UserLoginToken_token_index] ON [UserLoginToken]([token]);
|
CREATE INDEX [UserLoginToken_token_index] ON [UserLoginToken]([token]);
|
||||||
|
|
||||||
CREATE TABLE [Recipe] (
|
CREATE TABLE [Recipe] (
|
||||||
[id] INTEGER PRIMARY KEY,
|
[id] INTEGER PRIMARY KEY,
|
||||||
[user_id] INTEGER, -- Can be null if a user is deleted.
|
[user_id] INTEGER, -- Can be null if a user is deleted.
|
||||||
[title] TEXT NOT NULL,
|
[title] TEXT NOT NULL,
|
||||||
-- https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes
|
-- https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes
|
||||||
[lang] TEXT NOT NULL DEFAULT 'en',
|
[lang] TEXT NOT NULL DEFAULT 'en',
|
||||||
[estimated_time] INTEGER, -- in [s].
|
[estimated_time] INTEGER, -- in [s].
|
||||||
[description] TEXT NOT NULL DEFAULT '',
|
[description] TEXT NOT NULL DEFAULT '',
|
||||||
-- 0: Unknown, 1: Easy, 2: Medium, 4: Hard.
|
-- 0: Unknown, 1: Easy, 2: Medium, 4: Hard.
|
||||||
[difficulty] INTEGER NOT NULL DEFAULT 0,
|
[difficulty] INTEGER NOT NULL DEFAULT 0,
|
||||||
[servings] INTEGER DEFAULT 4,
|
[servings] INTEGER DEFAULT 4,
|
||||||
[is_published] INTEGER NOT NULL DEFAULT FALSE,
|
[is_published] INTEGER NOT NULL DEFAULT FALSE,
|
||||||
[creation_datetime] TEXT NOT NULL,
|
[creation_datetime] TEXT NOT NULL,
|
||||||
|
|
||||||
FOREIGN KEY([user_id]) REFERENCES [User]([id]) ON DELETE SET NULL
|
FOREIGN KEY([user_id]) REFERENCES [User]([id]) ON DELETE SET NULL
|
||||||
) STRICT;
|
) STRICT;
|
||||||
|
|
||||||
CREATE TRIGGER [Recipe_trigger_update_difficulty]
|
CREATE TRIGGER [Recipe_trigger_update_difficulty]
|
||||||
BEFORE UPDATE OF [difficulty]
|
BEFORE UPDATE OF [difficulty]
|
||||||
ON [Recipe]
|
ON [Recipe]
|
||||||
BEGIN
|
BEGIN
|
||||||
SELECT
|
SELECT
|
||||||
CASE
|
CASE
|
||||||
WHEN NEW.[difficulty] < 0 OR NEW.[difficulty] > 3 THEN
|
WHEN NEW.[difficulty] < 0 OR NEW.[difficulty] > 3 THEN
|
||||||
RAISE (ABORT, 'Invalid [difficulty] value')
|
RAISE (ABORT, 'Invalid [difficulty] value')
|
||||||
END;
|
END;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
CREATE TRIGGER [Recipe_trigger_insert_difficulty]
|
CREATE TRIGGER [Recipe_trigger_insert_difficulty]
|
||||||
BEFORE INSERT
|
BEFORE INSERT
|
||||||
ON [Recipe]
|
ON [Recipe]
|
||||||
BEGIN
|
BEGIN
|
||||||
SELECT
|
SELECT
|
||||||
CASE
|
CASE
|
||||||
WHEN NEW.[difficulty] < 0 OR NEW.[difficulty] > 3 THEN
|
WHEN NEW.[difficulty] < 0 OR NEW.[difficulty] > 3 THEN
|
||||||
RAISE (ABORT, 'Invalid [difficulty] value')
|
RAISE (ABORT, 'Invalid [difficulty] value')
|
||||||
END;
|
END;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
CREATE TABLE [Image] (
|
CREATE TABLE [Image] (
|
||||||
[Id] INTEGER PRIMARY KEY,
|
[Id] INTEGER PRIMARY KEY,
|
||||||
[recipe_id] INTEGER NOT NULL,
|
[recipe_id] INTEGER NOT NULL,
|
||||||
[name] TEXT NOT NULL DEFAULT '',
|
[name] TEXT NOT NULL DEFAULT '',
|
||||||
[description] TEXT NOT NULL DEFAULT '',
|
[description] TEXT NOT NULL DEFAULT '',
|
||||||
[image] BLOB NOT NULL,
|
[image] BLOB NOT NULL,
|
||||||
|
|
||||||
FOREIGN KEY([recipe_id]) REFERENCES [Recipe]([id]) ON DELETE CASCADE
|
FOREIGN KEY([recipe_id]) REFERENCES [Recipe]([id]) ON DELETE CASCADE
|
||||||
) STRICT;
|
) STRICT;
|
||||||
|
|
||||||
CREATE TABLE [RecipeTag] (
|
CREATE TABLE [RecipeTag] (
|
||||||
[id] INTEGER PRIMARY KEY,
|
[id] INTEGER PRIMARY KEY,
|
||||||
|
|
||||||
[recipe_id] INTEGER NOT NULL,
|
[recipe_id] INTEGER NOT NULL,
|
||||||
[tag_id] INTEGER NOT NULL,
|
[tag_id] INTEGER NOT NULL,
|
||||||
|
|
||||||
UNIQUE([recipe_id], [tag_id]),
|
UNIQUE([recipe_id], [tag_id]),
|
||||||
|
|
||||||
FOREIGN KEY([recipe_id]) REFERENCES [Recipe]([id]) ON DELETE CASCADE,
|
FOREIGN KEY([recipe_id]) REFERENCES [Recipe]([id]) ON DELETE CASCADE,
|
||||||
FOREIGN KEY([tag_id]) REFERENCES [Tag]([id]) ON DELETE CASCADE
|
FOREIGN KEY([tag_id]) REFERENCES [Tag]([id]) ON DELETE CASCADE
|
||||||
) STRICT;
|
) STRICT;
|
||||||
|
|
||||||
CREATE TABLE [Tag] (
|
CREATE TABLE [Tag] (
|
||||||
[id] INTEGER PRIMARY KEY,
|
[id] INTEGER PRIMARY KEY,
|
||||||
[name] TEXT NOT NULL
|
[name] TEXT NOT NULL
|
||||||
-- https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes
|
-- https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes
|
||||||
) STRICT;
|
) STRICT;
|
||||||
|
|
||||||
CREATE UNIQUE INDEX [Tag_name_lang_index] ON [Tag]([name]);
|
CREATE UNIQUE INDEX [Tag_name_lang_index] ON [Tag]([name]);
|
||||||
|
|
||||||
CREATE TABLE [Group] (
|
CREATE TABLE [Group] (
|
||||||
[id] INTEGER PRIMARY KEY,
|
[id] INTEGER PRIMARY KEY,
|
||||||
|
|
||||||
[order] INTEGER NOT NULL DEFAULT 0,
|
[order] INTEGER NOT NULL DEFAULT 0,
|
||||||
[recipe_id] INTEGER NOT NULL,
|
[recipe_id] INTEGER NOT NULL,
|
||||||
|
|
||||||
[name] TEXT NOT NULL DEFAULT '',
|
[name] TEXT NOT NULL DEFAULT '',
|
||||||
[comment] TEXT NOT NULL DEFAULT '',
|
[comment] TEXT NOT NULL DEFAULT '',
|
||||||
|
|
||||||
FOREIGN KEY([recipe_id]) REFERENCES [Recipe]([id]) ON DELETE CASCADE
|
FOREIGN KEY([recipe_id]) REFERENCES [Recipe]([id]) ON DELETE CASCADE
|
||||||
) STRICT;
|
) STRICT;
|
||||||
|
|
||||||
CREATE INDEX [Group_order_index] ON [Group]([order]);
|
CREATE INDEX [Group_order_index] ON [Group]([order]);
|
||||||
|
|
||||||
CREATE TABLE [Step] (
|
CREATE TABLE [Step] (
|
||||||
[id] INTEGER PRIMARY KEY,
|
[id] INTEGER PRIMARY KEY,
|
||||||
|
|
||||||
[order] INTEGER NOT NULL DEFAULT 0,
|
[order] INTEGER NOT NULL DEFAULT 0,
|
||||||
[group_id] INTEGER NOT NULL,
|
[group_id] INTEGER NOT NULL,
|
||||||
|
|
||||||
[action] TEXT NOT NULL DEFAULT '',
|
[action] TEXT NOT NULL DEFAULT '',
|
||||||
|
|
||||||
FOREIGN KEY(group_id) REFERENCES [Group](id) ON DELETE CASCADE
|
FOREIGN KEY(group_id) REFERENCES [Group](id) ON DELETE CASCADE
|
||||||
) STRICT;
|
) STRICT;
|
||||||
|
|
||||||
CREATE INDEX [Step_order_index] ON [Group]([order]);
|
CREATE INDEX [Step_order_index] ON [Group]([order]);
|
||||||
|
|
||||||
CREATE TABLE [Ingredient] (
|
CREATE TABLE [Ingredient] (
|
||||||
[id] INTEGER PRIMARY KEY,
|
[id] INTEGER PRIMARY KEY,
|
||||||
|
|
||||||
[order] INTEGER NOT NULL DEFAULT 0,
|
[order] INTEGER NOT NULL DEFAULT 0,
|
||||||
[step_id] INTEGER NOT NULL,
|
[step_id] INTEGER NOT NULL,
|
||||||
|
|
||||||
[name] TEXT NOT NULL DEFAULT '',
|
[name] TEXT NOT NULL DEFAULT '',
|
||||||
[quantity_value] REAL,
|
[quantity_value] REAL,
|
||||||
[quantity_unit] TEXT NOT NULL DEFAULT '',
|
[quantity_unit] TEXT NOT NULL DEFAULT '',
|
||||||
|
|
||||||
[comment] TEXT NOT NULL DEFAULT '',
|
[comment] TEXT NOT NULL DEFAULT '',
|
||||||
|
|
||||||
FOREIGN KEY([step_id]) REFERENCES [Step]([id]) ON DELETE CASCADE
|
FOREIGN KEY([step_id]) REFERENCES [Step]([id]) ON DELETE CASCADE
|
||||||
) STRICT;
|
) STRICT;
|
||||||
|
|
||||||
CREATE INDEX [Ingredient_order_index] ON [Ingredient]([order]);
|
CREATE INDEX [Ingredient_order_index] ON [Ingredient]([order]);
|
||||||
|
|
||||||
CREATE TABLE [RecipeScheduled] (
|
CREATE TABLE [RecipeScheduled] (
|
||||||
[id] INTEGER PRIMARY KEY,
|
[id] INTEGER PRIMARY KEY,
|
||||||
[user_id] INTEGER NOT NULL,
|
[user_id] INTEGER NOT NULL,
|
||||||
[recipe_id] INTEGER NOT NULL,
|
[recipe_id] INTEGER NOT NULL,
|
||||||
[date] TEXT NOT NULL, -- In form of 'YYYY-MM-DD'.
|
[date] TEXT NOT NULL, -- In form of 'YYYY-MM-DD'.
|
||||||
[servings] INTEGER, -- If NULL use [recipe].[servings].
|
[servings] INTEGER, -- If NULL use [recipe].[servings].
|
||||||
|
|
||||||
UNIQUE([user_id], [recipe_id], [date]),
|
UNIQUE([user_id], [recipe_id], [date]),
|
||||||
|
|
||||||
FOREIGN KEY([user_id]) REFERENCES [User]([id]) ON DELETE CASCADE,
|
FOREIGN KEY([user_id]) REFERENCES [User]([id]) ON DELETE CASCADE,
|
||||||
FOREIGN KEY([recipe_id]) REFERENCES [Recipe]([id]) ON DELETE CASCADE
|
FOREIGN KEY([recipe_id]) REFERENCES [Recipe]([id]) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX [RecipeScheduled_user_id_index] ON [RecipeScheduled]([user_id]);
|
CREATE INDEX [RecipeScheduled_user_id_index] ON [RecipeScheduled]([user_id]);
|
||||||
CREATE INDEX [RecipeScheduled_date_index] ON [RecipeScheduled]([date]);
|
CREATE INDEX [RecipeScheduled_date_index] ON [RecipeScheduled]([date]);
|
||||||
|
|
||||||
CREATE TABLE [ShoppingEntry] (
|
CREATE TABLE [ShoppingEntry] (
|
||||||
[id] INTEGER PRIMARY KEY,
|
[id] INTEGER PRIMARY KEY,
|
||||||
[user_id] INTEGER NOT NULL,
|
[user_id] INTEGER NOT NULL,
|
||||||
-- The linked ingredient can be deleted or a custom entry can be manually added.
|
-- The linked ingredient can be deleted or a custom entry can be manually added.
|
||||||
-- In both cases [name], [quantity_value] and [quantity_unit] are used to display
|
-- In both cases [name], [quantity_value], [quantity_unit] and [Servings] are used to display
|
||||||
-- the entry instead of [Ingredient] data.
|
-- the entry instead of [Ingredient] data.
|
||||||
[ingredient_id] INTEGER,
|
[ingredient_id] INTEGER,
|
||||||
[recipe_scheduled_id] INTEGER, -- Can be null when manually added.
|
[recipe_scheduled_id] INTEGER, -- Can be null when manually added.
|
||||||
|
|
||||||
[is_checked] INTEGER NOT NULL DEFAULT FALSE,
|
[is_checked] INTEGER NOT NULL DEFAULT FALSE,
|
||||||
|
|
||||||
[name] TEXT NOT NULL DEFAULT '',
|
-- The following four fields contain data only if [recipe_scheduled_id] is NULL.
|
||||||
[quantity_value] REAL,
|
[name] TEXT NOT NULL DEFAULT '',
|
||||||
[quantity_unit] TEXT NOT NULL DEFAULT '',
|
[quantity_value] REAL,
|
||||||
[servings] INTEGER,
|
[quantity_unit] TEXT NOT NULL DEFAULT '',
|
||||||
|
[servings] INTEGER,
|
||||||
FOREIGN KEY([user_id]) REFERENCES [User]([id]) ON DELETE CASCADE,
|
|
||||||
FOREIGN KEY([ingredient_id]) REFERENCES [Ingredient]([id]) ON DELETE SET NULL,
|
FOREIGN KEY([user_id]) REFERENCES [User]([id]) ON DELETE CASCADE,
|
||||||
FOREIGN KEY([recipe_scheduled_id]) REFERENCES [RecipeScheduled]([id]) ON DELETE SET NULL
|
FOREIGN KEY([ingredient_id]) REFERENCES [Ingredient]([id]) ON DELETE SET NULL,
|
||||||
);
|
FOREIGN KEY([recipe_scheduled_id]) REFERENCES [RecipeScheduled]([id]) ON DELETE SET NULL
|
||||||
|
);
|
||||||
CREATE INDEX [ShoppingEntry_user_id_index] ON [ShoppingEntry]([user_id]);
|
|
||||||
|
CREATE INDEX [ShoppingEntry_user_id_index] ON [ShoppingEntry]([user_id]);
|
||||||
-- When an ingredient is deleted, its values are copied to any shopping entry
|
|
||||||
-- that referenced it.
|
-- When an ingredient is deleted, its values are copied to any shopping entry
|
||||||
CREATE TRIGGER [Ingredient_trigger_delete]
|
-- that referenced it.
|
||||||
BEFORE DELETE
|
CREATE TRIGGER [Ingredient_trigger_delete]
|
||||||
ON [Ingredient]
|
BEFORE DELETE
|
||||||
BEGIN
|
ON [Ingredient]
|
||||||
UPDATE [ShoppingEntry]
|
BEGIN
|
||||||
SET
|
UPDATE [ShoppingEntry]
|
||||||
[name] = OLD.[name],
|
SET
|
||||||
[quantity_value] = OLD.[quantity_value],
|
[name] = OLD.[name],
|
||||||
[quantity_unit] = OLD.[quantity_unit],
|
[quantity_value] = OLD.[quantity_value],
|
||||||
[servings] = (
|
[quantity_unit] = OLD.[quantity_unit],
|
||||||
SELECT [servings]
|
[servings] = (
|
||||||
FROM [Recipe]
|
SELECT [servings]
|
||||||
INNER JOIN [Group] ON [Group].[recipe_id] = [Recipe].[id]
|
FROM [Recipe]
|
||||||
INNER JOIN [Step] ON [Step].[group_id] = [Group].[id]
|
INNER JOIN [Group] ON [Group].[recipe_id] = [Recipe].[id]
|
||||||
WHERE [Step].[id] = OLD.[step_id]
|
INNER JOIN [Step] ON [Step].[group_id] = [Group].[id]
|
||||||
)
|
WHERE [Step].[id] = OLD.[step_id]
|
||||||
WHERE [ingredient_id] = OLD.[id];
|
)
|
||||||
END;
|
WHERE [ingredient_id] = OLD.[id];
|
||||||
|
END;
|
||||||
CREATE TABLE [Settings] (
|
|
||||||
[name] TEXT NOT NULL PRIMARY KEY,
|
CREATE TABLE [Settings] (
|
||||||
|
[name] TEXT NOT NULL PRIMARY KEY,
|
||||||
-- Value can by anything that can be read from a text by
|
|
||||||
-- implementing the trait 'std::str::FromStr'.
|
-- Value can by anything that can be read from a text by
|
||||||
[value] TEXT NOT NULL
|
-- implementing the trait 'std::str::FromStr'.
|
||||||
) STRICT;
|
[value] TEXT NOT NULL
|
||||||
|
) STRICT;
|
||||||
INSERT INTO [Settings] ([name], [value]) VALUES ('new_user_registration_enabled', 'true');
|
|
||||||
|
INSERT INTO [Settings] ([name], [value]) VALUES ('new_user_registration_enabled', 'true');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue