add sqlite modify chatmessage

This commit is contained in:
chungyau97
2023-09-05 22:02:51 +08:00
parent 427ec32dc6
commit 22984618ca
3 changed files with 21 additions and 2 deletions
@@ -17,7 +17,7 @@ export class ChatMessage implements IChatMessage {
@Column({ type: 'text' })
content: string
@Column({ nullable: true })
@Column({ nullable: true, type: 'text' })
sourceDocuments?: string
@CreateDateColumn()
@@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class ModifyChatMessage1693921865247 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`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')));`
)
await queryRunner.query(
`INSERT INTO "temp_chat_message" ("id", "role", "chatflowid", "content", "sourceDocuments", "createdDate") SELECT "id", "role", "chatflowid", "content", "sourceDocuments", "createdDate" FROM "chat_message";`
)
await queryRunner.query(`DROP TABLE chat_message;`)
await queryRunner.query(`ALTER TABLE temp_chat_message RENAME TO chat_message;`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE temp_chat_message`)
}
}
@@ -1,4 +1,5 @@
import { Init1693835579790 } from './1693835579790-Init'
import { ModifyChatFlow1693920824108 } from './1693920824108-ModifyChatFlow'
import { ModifyChatMessage1693921865247 } from './1693921865247-ModifyChatMessage'
export const sqliteMigrations = [Init1693835579790, ModifyChatFlow1693920824108]
export const sqliteMigrations = [Init1693835579790, ModifyChatFlow1693920824108, ModifyChatMessage1693921865247]