refactor: replace focusedIndex with activeChildId
- Replace focusedIndex integer with activeChildId string in messages schema - Add migration to convert existing data and drop focused_index column - Add hooks for providers.updatedAt and messageParts.lastUpdatedAt - Add file size column to files table - Update message navigation to use child ID-based lookup - Simplify delete logic by removing focusedIndex math - Fix file delete endpoint filename ([id[ -> [id])
This commit is contained in:
+4
-3
@@ -55,7 +55,7 @@ export const providers = pgTable('providers', {
|
||||
apiProxyUrl?: string;
|
||||
}>().default({}),
|
||||
createdAt: timestamp('created_at').notNull().defaultNow(),
|
||||
updatedAt: timestamp('updated_at').notNull().defaultNow(),
|
||||
updatedAt: timestamp('updated_at').notNull().defaultNow().$onUpdate(() => /* @__PURE__ */ new Date()),
|
||||
}, (table) => [
|
||||
index('providers_userId_idx').on(table.userId),
|
||||
]);
|
||||
@@ -134,7 +134,7 @@ export const messages = pgTable('messages', {
|
||||
generationId: text('generation_id').references(() => generations.id, { onDelete: 'cascade' }),
|
||||
role: roleEnum('role').notNull(),
|
||||
content: text('content'),
|
||||
focusedIndex: integer('focused_index'),
|
||||
activeChildId: text('active_child_id'),
|
||||
deleted: boolean('deleted').default(false),
|
||||
updatedAt: timestamp('updated_at').notNull().defaultNow().$onUpdate(() => /* @__PURE__ */ new Date()),
|
||||
createdAt: timestamp('created_at').notNull().defaultNow(),
|
||||
@@ -155,7 +155,7 @@ export const messageParts = pgTable('message_parts', {
|
||||
providerOptions: jsonb('provider_options'),
|
||||
finished: boolean('finished').notNull().default(false),
|
||||
createdAt: timestamp('created_at').notNull().defaultNow(),
|
||||
lastUpdatedAt: timestamp('last_updated_at').notNull().defaultNow(),
|
||||
lastUpdatedAt: timestamp('last_updated_at').notNull().defaultNow().$onUpdate(() => /* @__PURE__ */ new Date()),
|
||||
}, (table) => [
|
||||
index('message_parts_topicId_idx').on(table.topicId),
|
||||
index('message_parts_messageId_idx').on(table.messageId),
|
||||
@@ -212,6 +212,7 @@ export const files = pgTable('files', {
|
||||
userId: text('user_id').notNull(),
|
||||
name: text('name').notNull(),
|
||||
mimeType: text('mime_type').notNull(),
|
||||
size: integer('size').notNull().default(0),
|
||||
url: text('url').notNull(),
|
||||
createdAt: timestamp('created_at').notNull().defaultNow(),
|
||||
}, (table) => [
|
||||
|
||||
Reference in New Issue
Block a user