Add frontend tests and other stuff
[recipes.git] / backend / sql / version_1.sql
index 1685cd1..c3488db 100644 (file)
@@ -42,10 +42,41 @@ CREATE TABLE [Recipe] (
     [estimate_time] INTEGER,
     [description] TEXT,
     [servings] INTEGER DEFAULT 4,
+    [is_published] INTEGER NOT NULL DEFAULT FALSE,
 
     FOREIGN KEY([user_id]) REFERENCES [User]([id]) ON DELETE SET NULL
 );
 
+CREATE TABLE [Image] (
+    [Id] INTEGER PRIMARY KEY,
+    [recipe_id] INTEGER NOT NULL,
+    [name] TEXT,
+    [description] TEXT,
+    [image] BLOB,
+
+    FOREIGN KEY([recipe_id]) REFERENCES [Recipe]([id]) ON DELETE CASCADE
+);
+
+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,