mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 19:41:09 +02:00
🔧 fix(chat): update schema for Better Auth nanoid user IDs
- Change userId columns from uuid to text to support Better Auth's nanoid format - Update conversations, spaces, space_members, templates, usage_logs schemas - Fix web API endpoint path from /api to /api/v1 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
3799fe1b54
commit
fb9945c0f7
5 changed files with 8 additions and 8 deletions
|
|
@ -10,7 +10,7 @@ export const conversationModeEnum = pgEnum('conversation_mode', ['free', 'guided
|
|||
|
||||
export const conversations = pgTable('conversations', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
userId: uuid('user_id').notNull(),
|
||||
userId: text('user_id').notNull(), // TEXT to support Better Auth nanoid format
|
||||
modelId: uuid('model_id').references(() => models.id),
|
||||
templateId: uuid('template_id').references(() => templates.id),
|
||||
spaceId: uuid('space_id').references(() => spaces.id, { onDelete: 'set null' }),
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export const invitationStatusEnum = pgEnum('invitation_status', [
|
|||
|
||||
export const spaces = pgTable('spaces', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
ownerId: uuid('owner_id').notNull(),
|
||||
ownerId: text('owner_id').notNull(), // TEXT to support Better Auth nanoid format
|
||||
name: text('name').notNull(),
|
||||
description: text('description'),
|
||||
isArchived: boolean('is_archived').default(false).notNull(),
|
||||
|
|
@ -23,10 +23,10 @@ export const spaceMembers = pgTable('space_members', {
|
|||
spaceId: uuid('space_id')
|
||||
.references(() => spaces.id, { onDelete: 'cascade' })
|
||||
.notNull(),
|
||||
userId: uuid('user_id').notNull(),
|
||||
userId: text('user_id').notNull(), // TEXT to support Better Auth nanoid format
|
||||
role: memberRoleEnum('role').default('member').notNull(),
|
||||
invitationStatus: invitationStatusEnum('invitation_status').default('pending').notNull(),
|
||||
invitedBy: uuid('invited_by'),
|
||||
invitedBy: text('invited_by'), // TEXT to support Better Auth nanoid format
|
||||
invitedAt: timestamp('invited_at', { withTimezone: true }).defaultNow().notNull(),
|
||||
joinedAt: timestamp('joined_at', { withTimezone: true }),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { models } from './models.schema';
|
|||
|
||||
export const templates = pgTable('templates', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
userId: uuid('user_id').notNull(),
|
||||
userId: text('user_id').notNull(), // TEXT to support Better Auth nanoid format
|
||||
name: text('name').notNull(),
|
||||
description: text('description'),
|
||||
systemPrompt: text('system_prompt').notNull(),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { pgTable, uuid, timestamp, integer, numeric } from 'drizzle-orm/pg-core';
|
||||
import { pgTable, uuid, text, timestamp, integer, numeric } from 'drizzle-orm/pg-core';
|
||||
import { relations } from 'drizzle-orm';
|
||||
import { conversations } from './conversations.schema';
|
||||
import { messages } from './messages.schema';
|
||||
|
|
@ -12,7 +12,7 @@ export const usageLogs = pgTable('usage_logs', {
|
|||
messageId: uuid('message_id')
|
||||
.references(() => messages.id, { onDelete: 'cascade' })
|
||||
.notNull(),
|
||||
userId: uuid('user_id').notNull(),
|
||||
userId: text('user_id').notNull(), // TEXT to support Better Auth nanoid format
|
||||
modelId: uuid('model_id').references(() => models.id),
|
||||
promptTokens: integer('prompt_tokens').default(0).notNull(),
|
||||
completionTokens: integer('completion_tokens').default(0).notNull(),
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ async function fetchApi<T>(
|
|||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/api${endpoint}`, {
|
||||
const response = await fetch(`${API_BASE}/api/v1${endpoint}`, {
|
||||
method,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue