Add users table to Drizzle schema (task 2.1)

Adds the `users` table to `src/lib/db/schema.ts` with:
- UUID primary key (defaultRandom)
- email (unique, not null)
- password_hash (nullable, for OAuth-only users)
- name, image (nullable)
- provider (default 'credentials'), provider_account_id (nullable)
- email_verified (timestamp, nullable)
- created_at, updated_at

Marks task 2.1 as complete in tasks.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marko Djordjevic 2026-02-20 09:46:20 +01:00
parent d05ed21cd6
commit 9101cfb7af
2 changed files with 15 additions and 2 deletions

View file

@ -6,7 +6,7 @@
## 2. Database Schema & Migration
- [ ] 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.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
- [ ] 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)`
- [ ] 2.4 `[haiku]` Generate Drizzle migration with `drizzle-kit generate`

View file

@ -1,4 +1,17 @@
import { pgTable, serial, text, timestamp, doublePrecision, integer, boolean, jsonb, uniqueIndex } from 'drizzle-orm/pg-core';
import { pgTable, serial, text, timestamp, doublePrecision, integer, boolean, jsonb, uniqueIndex, uuid } from 'drizzle-orm/pg-core';
export const users = pgTable('users', {
id: uuid('id').primaryKey().defaultRandom(),
email: text('email').notNull().unique(),
password_hash: text('password_hash'), // null for OAuth-only users
name: text('name'),
image: text('image'),
provider: text('provider').notNull().default('credentials'), // 'credentials' | 'google'
provider_account_id: text('provider_account_id'), // Google sub ID
email_verified: timestamp('email_verified'), // nullable — set when email is verified
created_at: timestamp('created_at').notNull().defaultNow(),
updated_at: timestamp('updated_at').notNull().defaultNow(),
});
export const charts = pgTable('charts', {
id: serial('id').primaryKey(),