X-Git-Url: http://git.euphorik.ch/?p=recipes.git;a=blobdiff_plain;f=backend%2Fsql%2Fversion_1.sql;fp=backend%2Fsql%2Fversion_1.sql;h=93f567b5389ccde84f2378d33269769108baedb8;hp=1685cd1072c1b5e99285394742e55c60aa49c683;hb=d28e765e39e70ad2ab9a42885c786d5d8ba9ba40;hpb=8a3fef096d720666dc8a54789aee02250642d8a1 diff --git a/backend/sql/version_1.sql b/backend/sql/version_1.sql index 1685cd1..93f567b 100644 --- a/backend/sql/version_1.sql +++ b/backend/sql/version_1.sql @@ -46,6 +46,26 @@ CREATE TABLE [Recipe] ( FOREIGN KEY([user_id]) REFERENCES [User]([id]) ON DELETE SET NULL ); +CREATE TABLE [RecipeTag] ( + [id] INTEGER PRIMARY KEY, + + [recipe_id] INTEGER NOT NULL, + [tag_id] INTEGER NO NULL, + + FOREIGN KEY([recipe_id]) REFERENCES [Recipe]([id]) ON DELETE CASCADE, + FOREIGN KEY([tag_id]) REFERENCES [Tag]([id]) ON DELETE CASCADE +); + +CREATE TABLE [Tag] ( + [id] INTEGER PRIMARY KEY, + [recipe_tag_id] INTEGER, + [name] TEXT NOT NULL, + + FOREIGN KEY([recipe_tag_id]) REFERENCES [RecipeTag]([id]) ON DELETE SET NULL +); + +CREATE UNIQUE INDEX [Tag_name_index] ON [Tag] ([name]); + CREATE TABLE [Quantity] ( [id] INTEGER PRIMARY KEY, [value] REAL,