9 lines
359 B
MySQL
9 lines
359 B
MySQL
|
|
CREATE TABLE recipe_views (
|
||
|
|
profile_id INTEGER NOT NULL REFERENCES profile(id) ON DELETE CASCADE,
|
||
|
|
recipe_id INTEGER NOT NULL REFERENCES recipe(id) ON DELETE CASCADE,
|
||
|
|
last_viewed_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||
|
|
PRIMARY KEY (profile_id, recipe_id)
|
||
|
|
);
|
||
|
|
CREATE INDEX idx_recipe_views_recent
|
||
|
|
ON recipe_views (profile_id, last_viewed_at DESC);
|