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:
Wuesteon 2025-12-09 16:24:22 +01:00
parent 582c6f58a4
commit 4e63f3f74b
9 changed files with 87 additions and 16 deletions

View file

@ -32,11 +32,37 @@ All authentication is handled by **Mana Core Auth**, a centralized authenticatio
<──────────────────────│ │
```
## User ID Format
**CRITICAL**: Mana Core Auth uses Better Auth, which generates **non-UUID user IDs**.
```
Example user ID: otUe1YrfENPdHnrF3g1vSBfpkQfambCZ
```
**Format details:**
- 32 characters
- Base62 alphabet (a-z, A-Z, 0-9)
- ~190 bits of entropy (more than UUID's 122 bits)
- NOT a valid UUID format
**Database schema implications:**
```typescript
// CORRECT - use text for user_id
userId: text('user_id').notNull(),
// WRONG - will cause "invalid input syntax for type uuid" errors
userId: uuid('user_id').notNull(),
```
Always use `text` type for `user_id` columns in all database schemas.
## Token Structure (EdDSA JWT)
```json
{
"sub": "user-uuid-123",
"sub": "otUe1YrfENPdHnrF3g1vSBfpkQfambCZ",
"email": "user@example.com",
"role": "user",
"sid": "session-id-456",
@ -47,6 +73,8 @@ All authentication is handled by **Mana Core Auth**, a centralized authenticatio
}
```
**Note**: The `sub` claim contains the Better Auth user ID (not a UUID).
**Important**: Keep claims minimal. Do NOT include:
- Credit balance (changes frequently)
- Organization data (use API instead)