Task 2.3: Replace single-column unique constraints with composite (user_id, name) unique indexes

- charts.name → uniqueIndex('charts_user_id_name_unique').on(user_id, name)
- annotation_types.name → uniqueIndex('annotation_types_user_id_name_unique').on(user_id, name)
- span_label_types.name → uniqueIndex('span_label_types_user_id_name_unique').on(user_id, name)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marko Djordjevic 2026-02-20 09:48:50 +01:00
parent 0cd74ebedd
commit b633a3f52a
2 changed files with 13 additions and 7 deletions

View file

@ -8,7 +8,7 @@
- [x] 2.1 `[sonnet]` Add `users` table to Drizzle schema (`src/lib/db/schema.ts`) with UUID PK, email, password_hash, name, image, provider, provider_account_id, email_verified, created_at, updated_at
- [x] 2.2 `[sonnet]` Add `user_id` (uuid, FK to users.id) column to `charts`, `annotations`, `annotation_types`, `span_annotations`, `span_label_types` in schema
- [ ] 2.3 `[sonnet]` Replace unique constraints: `charts.name``(user_id, name)`, `annotation_types.name``(user_id, name)`, `span_label_types.name``(user_id, name)`
- [x] 2.3 `[sonnet]` Replace unique constraints: `charts.name``(user_id, name)`, `annotation_types.name``(user_id, name)`, `span_label_types.name``(user_id, name)`
- [ ] 2.4 `[haiku]` Generate Drizzle migration with `drizzle-kit generate`
- [ ] 2.5 `[opus]` Create data migration script (`scripts/migrate-users.ts`): create default admin user, backfill `user_id` on all existing rows, alter columns to NOT NULL