From 6722589b515ccee267212cf783fc0ebbaa20cd90 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Mon, 27 Jul 2026 17:18:40 +0200 Subject: feat: catalog section + deduplicate items by name - Show all items split into List (unchecked) and Catalog (checked) sections - Tapping a catalog item unchecks it (returns to list) - Add action now upserts: unchecks existing item instead of creating duplicate - UNIQUE constraint on groceries.name as defense-in-depth - Tests for dedup behavior (insert, re-add from catalog, no-op on list) --- src/lib/server/db/schema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/server/db/schema.ts') diff --git a/src/lib/server/db/schema.ts b/src/lib/server/db/schema.ts index a8527fd..403ef51 100644 --- a/src/lib/server/db/schema.ts +++ b/src/lib/server/db/schema.ts @@ -2,7 +2,7 @@ import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core'; export const groceries = sqliteTable('groceries', { id: integer('id').primaryKey({ autoIncrement: true }), - name: text('name').notNull(), + name: text('name').notNull().unique(), checked: integer('checked', { mode: 'boolean' }).notNull().default(false), createdAt: text('created_at').notNull(), }); -- cgit v1.3