Skip to content

Commit 5011cd6

Browse files
author
Vianpyro
committed
Add last_login update procedure and fix recipe_status foreign key reference
1 parent a28c23c commit 5011cd6

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

database.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ CREATE OR REPLACE TABLE recipe (
104104
recipe_status TINYINT NOT NULL DEFAULT 1,
105105
FOREIGN KEY (author_id) REFERENCES person (person_id) ON DELETE SET NULL,
106106
FOREIGN KEY (picture_id) REFERENCES picture (picture_id) ON DELETE CASCADE,
107-
FOREIGN KEY (recipe_status) REFERENCES recipe_status (id) ON DELETE RESTRICT
107+
FOREIGN KEY (recipe_status) REFERENCES recipe_status (status_id) ON DELETE RESTRICT
108108
) ENGINE = InnoDB;
109109

110110
CREATE OR REPLACE TABLE recipe_ingredient (

procedures/update/person.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ USE smartcooking;
33

44
DELIMITER //
55

6+
CREATE OR REPLACE PROCEDURE update_last_login(
7+
IN p_person_id INT
8+
)
9+
BEGIN
10+
UPDATE person
11+
SET last_login = NOW()
12+
WHERE person_id = p_person_id;
13+
END //
14+
615
CREATE OR REPLACE PROCEDURE update_person(
716
IN p_person_id INT,
817
IN p_name VARCHAR(100),

setup/z_mock/recipe.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
USE smartcooking;
33

44
-- Fill the database with mock data
5-
CALL insert_recipe(1, 1, 30, 3, 'www.source.com', 'draft');
6-
CALL insert_recipe(2, 2, 45, 2, 'www.source.com', 'pending review');
7-
CALL insert_recipe(3, 3, 60, 1, 'www.source.com', 'draft');
8-
CALL insert_recipe(4, 4, 75, 3, 'www.source.com', 'pending review');
9-
CALL insert_recipe(4, 5, 90, 2, 'www.source.com', 'draft');
5+
CALL insert_recipe(1, 1, 30, 3, 'www.source.com', 1);
6+
CALL insert_recipe(2, 2, 45, 2, 'www.source.com', 2);
7+
CALL insert_recipe(3, 3, 60, 1, 'www.source.com', 1);
8+
CALL insert_recipe(4, 4, 75, 3, 'www.source.com', 3);
9+
CALL insert_recipe(4, 5, 90, 2, 'www.source.com', 1);

0 commit comments

Comments
 (0)