diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-07-27 17:18:40 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-07-27 17:18:40 +0200 |
| commit | 6722589b515ccee267212cf783fc0ebbaa20cd90 (patch) | |
| tree | 1220bf320a47dc5fe8a438da8443c788555f8edb /src/lib/server/db/schema.ts | |
| parent | 6cde16e66ddcb95f55aa2195910260d9b1faa88b (diff) | |
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)
Diffstat (limited to 'src/lib/server/db/schema.ts')
| -rw-r--r-- | src/lib/server/db/schema.ts | 2 |
1 files changed, 1 insertions, 1 deletions
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(), }); |
