mirror of
https://github.com/lobehub/lobehub
synced 2026-04-21 17:47:27 +00:00
💾 chore(database): sync document history schema indexes
This commit is contained in:
parent
d526b40b78
commit
7c8f721d6d
3 changed files with 21 additions and 16 deletions
|
|
@ -11,5 +11,6 @@ ALTER TABLE "document_histories" DROP CONSTRAINT IF EXISTS "document_histories_d
|
|||
ALTER TABLE "document_histories" ADD CONSTRAINT "document_histories_document_id_documents_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."documents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "document_histories" DROP CONSTRAINT IF EXISTS "document_histories_user_id_users_id_fk";--> statement-breakpoint
|
||||
ALTER TABLE "document_histories" ADD CONSTRAINT "document_histories_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX IF NOT EXISTS "document_histories_document_id_saved_at_idx" ON "document_histories" USING btree ("document_id","saved_at");--> statement-breakpoint
|
||||
CREATE INDEX IF NOT EXISTS "document_histories_user_id_saved_at_idx" ON "document_histories" USING btree ("user_id","saved_at");
|
||||
CREATE INDEX IF NOT EXISTS "document_histories_document_id_idx" ON "document_histories" USING btree ("document_id");--> statement-breakpoint
|
||||
CREATE INDEX IF NOT EXISTS "document_histories_user_id_idx" ON "document_histories" USING btree ("user_id");--> statement-breakpoint
|
||||
CREATE INDEX IF NOT EXISTS "document_histories_saved_at_idx" ON "document_histories" USING btree ("saved_at");
|
||||
|
|
|
|||
|
|
@ -3903,20 +3903,14 @@
|
|||
}
|
||||
},
|
||||
"indexes": {
|
||||
"document_histories_document_id_saved_at_idx": {
|
||||
"name": "document_histories_document_id_saved_at_idx",
|
||||
"document_histories_document_id_idx": {
|
||||
"name": "document_histories_document_id_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "document_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
},
|
||||
{
|
||||
"expression": "saved_at",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
|
|
@ -3924,15 +3918,24 @@
|
|||
"method": "btree",
|
||||
"with": {}
|
||||
},
|
||||
"document_histories_user_id_saved_at_idx": {
|
||||
"name": "document_histories_user_id_saved_at_idx",
|
||||
"document_histories_user_id_idx": {
|
||||
"name": "document_histories_user_id_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "user_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
},
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
},
|
||||
"document_histories_saved_at_idx": {
|
||||
"name": "document_histories_saved_at_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "saved_at",
|
||||
"isExpression": false,
|
||||
|
|
|
|||
|
|
@ -21,13 +21,14 @@ export const documentHistories = pgTable(
|
|||
|
||||
editorData: jsonb('editor_data').$type<Record<string, any>>().notNull(),
|
||||
saveSource: text('save_source', {
|
||||
enum: ['autosave', 'manual', 'restore', 'system'],
|
||||
enum: ['autosave', 'manual', 'restore', 'system', 'llm_call'],
|
||||
}).notNull(),
|
||||
savedAt: timestamptz('saved_at').notNull(),
|
||||
},
|
||||
(table) => [
|
||||
index('document_histories_document_id_saved_at_idx').on(table.documentId, table.savedAt),
|
||||
index('document_histories_user_id_saved_at_idx').on(table.userId, table.savedAt),
|
||||
index('document_histories_document_id_idx').on(table.documentId),
|
||||
index('document_histories_user_id_idx').on(table.userId),
|
||||
index('document_histories_saved_at_idx').on(table.savedAt),
|
||||
],
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue