refactor(views): ON CONFLICT DO UPDATE statt INSERT OR REPLACE
Code-Review-Finding zu commit6c8de6f: INSERT OR REPLACE ist intern DELETE+INSERT, das wuerde eventuelle FK-Children kuenftig stillschweigend mitloeschen. ON CONFLICT DO UPDATE bumpt nur das Timestamp-Feld und matcht den Stil der anderen Repos (shopping/repository.ts:43). Migration-Dateiname zu recipe_view (singular) angeglichen, matcht jetzt den Tabellennamen aus543008b. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
10
src/lib/server/db/migrations/014_recipe_view.sql
Normal file
10
src/lib/server/db/migrations/014_recipe_view.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
-- Merkt je Profil, wann ein Rezept zuletzt angesehen wurde.
|
||||
-- Dient als Basis fuer "Zuletzt gesehen"-Sortierung auf der Startseite.
|
||||
CREATE TABLE recipe_view (
|
||||
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 TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (profile_id, recipe_id)
|
||||
);
|
||||
CREATE INDEX idx_recipe_view_recent
|
||||
ON recipe_view (profile_id, last_viewed_at DESC);
|
||||
Reference in New Issue
Block a user