Skip to content

Commit 2298461

Browse files
committed
add sqlite modify chatmessage
1 parent 427ec32 commit 2298461

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

packages/server/src/database/entities/ChatMessage.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class ChatMessage implements IChatMessage {
1717
@Column({ type: 'text' })
1818
content: string
1919

20-
@Column({ nullable: true })
20+
@Column({ nullable: true, type: 'text' })
2121
sourceDocuments?: string
2222

2323
@CreateDateColumn()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm'
2+
3+
export class ModifyChatMessage1693921865247 implements MigrationInterface {
4+
public async up(queryRunner: QueryRunner): Promise<void> {
5+
await queryRunner.query(
6+
`CREATE TABLE "temp_chat_message" ("id" varchar PRIMARY KEY NOT NULL, "role" varchar NOT NULL, "chatflowid" varchar NOT NULL, "content" text NOT NULL, "sourceDocuments" text, "createdDate" datetime NOT NULL DEFAULT (datetime('now')));`
7+
)
8+
await queryRunner.query(
9+
`INSERT INTO "temp_chat_message" ("id", "role", "chatflowid", "content", "sourceDocuments", "createdDate") SELECT "id", "role", "chatflowid", "content", "sourceDocuments", "createdDate" FROM "chat_message";`
10+
)
11+
await queryRunner.query(`DROP TABLE chat_message;`)
12+
await queryRunner.query(`ALTER TABLE temp_chat_message RENAME TO chat_message;`)
13+
}
14+
15+
public async down(queryRunner: QueryRunner): Promise<void> {
16+
await queryRunner.query(`DROP TABLE temp_chat_message`)
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Init1693835579790 } from './1693835579790-Init'
22
import { ModifyChatFlow1693920824108 } from './1693920824108-ModifyChatFlow'
3+
import { ModifyChatMessage1693921865247 } from './1693921865247-ModifyChatMessage'
34

4-
export const sqliteMigrations = [Init1693835579790, ModifyChatFlow1693920824108]
5+
export const sqliteMigrations = [Init1693835579790, ModifyChatFlow1693920824108, ModifyChatMessage1693921865247]

0 commit comments

Comments
 (0)