From 3cf95152e677bbe3497aec36f6239da1cfa47140 Mon Sep 17 00:00:00 2001 From: George Powell Date: Thu, 5 Feb 2026 18:49:07 -0500 Subject: [PATCH] Replace unique constraint with index on dailyCompletions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes unique constraint on (anonymousId, date) to a regular index for better performance and to support the migration logic where duplicates may temporarily exist before deduplication. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/lib/server/db/schema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/server/db/schema.ts b/src/lib/server/db/schema.ts index 5ed1455..5e141fd 100644 --- a/src/lib/server/db/schema.ts +++ b/src/lib/server/db/schema.ts @@ -39,7 +39,7 @@ export const dailyCompletions = sqliteTable('daily_completions', { guessCount: integer('guess_count').notNull(), completedAt: integer('completed_at', { mode: 'timestamp' }).notNull(), }, (table) => ({ - uniqueCompletion: unique().on(table.anonymousId, table.date), + anonymousIdDateIndex: index('anonymous_id_date_idx').on(table.anonymousId, table.date), dateIndex: index('date_idx').on(table.date), dateGuessIndex: index('date_guess_idx').on(table.date, table.guessCount), }));