mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-23 05:46:43 +02:00
fix(todo): use TEXT for user_id columns (Better Auth compatibility)
Better Auth generates non-UUID user IDs (e.g., otUe1YrfENPdHnrF3g1vSBfpkQfambCZ). Changed all user_id columns from uuid to text type to prevent "invalid input syntax for type uuid" errors. Also documented this requirement in: - .claude/guidelines/authentication.md (new User ID Format section) - .claude/guidelines/database.md (User ID Column Type section) - apps/todo/CLAUDE.md (Database Schema section) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
582c6f58a4
commit
4e63f3f74b
9 changed files with 87 additions and 16 deletions
|
|
@ -101,6 +101,26 @@ src/db/
|
|||
└── migrations/ # Generated migrations
|
||||
```
|
||||
|
||||
### User ID Column Type
|
||||
|
||||
**CRITICAL**: Always use `text` for `user_id` columns, NOT `uuid`.
|
||||
|
||||
Mana Core Auth (Better Auth) generates non-UUID user IDs:
|
||||
|
||||
```
|
||||
Example: otUe1YrfENPdHnrF3g1vSBfpkQfambCZ
|
||||
```
|
||||
|
||||
```typescript
|
||||
// CORRECT
|
||||
userId: text('user_id').notNull(),
|
||||
|
||||
// WRONG - causes "invalid input syntax for type uuid" errors
|
||||
userId: uuid('user_id').notNull(),
|
||||
```
|
||||
|
||||
See [Authentication Guidelines](./authentication.md#user-id-format) for details.
|
||||
|
||||
### Table Definition Pattern
|
||||
|
||||
```typescript
|
||||
|
|
@ -123,8 +143,10 @@ export const files = pgTable(
|
|||
// Primary key - always UUID with auto-generation
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
|
||||
// Foreign keys
|
||||
userId: varchar('user_id', { length: 255 }).notNull(),
|
||||
// User ID - always TEXT (Better Auth uses non-UUID format)
|
||||
userId: text('user_id').notNull(),
|
||||
|
||||
// Foreign keys to other tables (UUIDs are fine)
|
||||
parentFolderId: uuid('parent_folder_id').references(() => folders.id, { onDelete: 'set null' }),
|
||||
|
||||
// Required fields
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue