mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-26 13:19:34 +07:00
Sync main branch to canary branch (#12308)
Automatic sync ## Summary by Sourcery Extend database schemas and migrations to support async task inference tracking and typed generation topics. New Features: - Add an inferenceId field to async tasks with a dedicated index for lookup by inference ID. - Add a typed generation topic field to distinguish between image and video topics with a default of image. Enhancements: - Update database schema metadata and documentation snapshots to reflect the new async task and generation topic fields. Tests: - Adjust async task and generation topic tests to cover the new inferenceId and topic type fields.
This commit is contained in:
@@ -201,6 +201,7 @@ table async_tasks {
|
||||
type text
|
||||
status text
|
||||
error jsonb
|
||||
inference_id text
|
||||
user_id text [not null]
|
||||
duration integer
|
||||
parent_id uuid
|
||||
@@ -213,6 +214,7 @@ table async_tasks {
|
||||
user_id [name: 'async_tasks_user_id_idx']
|
||||
parent_id [name: 'async_tasks_parent_id_idx']
|
||||
(type, status) [name: 'async_tasks_type_status_idx']
|
||||
inference_id [name: 'async_tasks_inference_id_idx']
|
||||
metadata [name: 'async_tasks_metadata_idx']
|
||||
}
|
||||
}
|
||||
@@ -479,6 +481,7 @@ table generation_topics {
|
||||
user_id text [not null]
|
||||
title text
|
||||
cover_url text
|
||||
type varchar(32) [not null, default: 'image']
|
||||
accessed_at "timestamp with time zone" [not null, default: `now()`]
|
||||
created_at "timestamp with time zone" [not null, default: `now()`]
|
||||
updated_at "timestamp with time zone" [not null, default: `now()`]
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE "async_tasks" ADD COLUMN IF NOT EXISTS "inference_id" text;--> statement-breakpoint
|
||||
ALTER TABLE "generation_topics" ADD COLUMN IF NOT EXISTS "type" varchar(32) DEFAULT 'image' NOT NULL;--> statement-breakpoint
|
||||
CREATE INDEX IF NOT EXISTS "async_tasks_inference_id_idx" ON "async_tasks" USING btree ("inference_id");
|
||||
12134
packages/database/migrations/meta/0086_snapshot.json
Normal file
12134
packages/database/migrations/meta/0086_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -602,7 +602,14 @@
|
||||
"when": 1770632176750,
|
||||
"tag": "0085_remove_id_unique_constraint",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 86,
|
||||
"version": "7",
|
||||
"when": 1770955654188,
|
||||
"tag": "0086_video_generation_schema",
|
||||
"breakpoints": true
|
||||
}
|
||||
],
|
||||
"version": "6"
|
||||
}
|
||||
}
|
||||
@@ -532,6 +532,7 @@ describe('GenerationModel', () => {
|
||||
params: {},
|
||||
error: null,
|
||||
duration: null,
|
||||
inferenceId: null,
|
||||
accessedAt: new Date(),
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
|
||||
@@ -12,6 +12,7 @@ export const asyncTasks = pgTable(
|
||||
|
||||
status: text('status'),
|
||||
error: jsonb('error'),
|
||||
inferenceId: text('inference_id'),
|
||||
|
||||
userId: text('user_id')
|
||||
.references(() => users.id, { onDelete: 'cascade' })
|
||||
@@ -26,10 +27,8 @@ export const asyncTasks = pgTable(
|
||||
index('async_tasks_user_id_idx').on(t.userId),
|
||||
index('async_tasks_parent_id_idx').on(t.parentId),
|
||||
index('async_tasks_type_status_idx').on(t.type, t.status),
|
||||
index('async_tasks_metadata_idx').using(
|
||||
'gin',
|
||||
t.metadata,
|
||||
)
|
||||
index('async_tasks_inference_id_idx').on(t.inferenceId),
|
||||
index('async_tasks_metadata_idx').using('gin', t.metadata)
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@@ -31,6 +31,9 @@ export const generationTopics = pgTable(
|
||||
/** Topic cover image URL */
|
||||
coverUrl: text('cover_url'),
|
||||
|
||||
/** Topic type: 'image' or 'video' */
|
||||
type: varchar('type', { length: 32 }).notNull().default('image'),
|
||||
|
||||
...timestamps,
|
||||
},
|
||||
(t) => [index('generation_topics_user_id_idx').on(t.userId)],
|
||||
|
||||
@@ -55,6 +55,7 @@ describe('generationTopicRouter', () => {
|
||||
title: 'Test Topic 1',
|
||||
userId: 'test-user',
|
||||
coverUrl: 'cover-url-1',
|
||||
type: 'image',
|
||||
accessedAt: new Date(),
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
@@ -64,6 +65,7 @@ describe('generationTopicRouter', () => {
|
||||
title: 'Test Topic 2',
|
||||
userId: 'test-user',
|
||||
coverUrl: null,
|
||||
type: 'image',
|
||||
accessedAt: new Date(),
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date(),
|
||||
|
||||
Reference in New Issue
Block a user