Merge branch 'main' into FEATURE/UI-Updates

# Conflicts:
#	packages/server/src/database/migrations/mysql/index.ts
#	packages/server/src/database/migrations/postgres/index.ts
#	packages/server/src/database/migrations/sqlite/index.ts
This commit is contained in:
Henry
2023-11-20 12:18:23 +00:00
29 changed files with 861 additions and 88 deletions
@@ -23,6 +23,9 @@ export class ChatMessage implements IChatMessage {
@Column({ nullable: true, type: 'text' })
usedTools?: string
@Column({ nullable: true, type: 'text' })
fileAnnotations?: string
@Column()
chatType: string
@@ -0,0 +1,12 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddFileAnnotationsToChatMessage1700271021237 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const columnExists = await queryRunner.hasColumn('chat_message', 'fileAnnotations')
if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_message\` ADD COLUMN \`fileAnnotations\` TEXT;`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`chat_message\` DROP COLUMN \`fileAnnotations\`;`)
}
}
@@ -9,6 +9,7 @@ import { AddChatHistory1694658767766 } from './1694658767766-AddChatHistory'
import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity'
import { AddUsedToolsToChatMessage1699481607341 } from './1699481607341-AddUsedToolsToChatMessage'
import { AddCategoryToChatFlow1699900910291 } from './1699900910291-AddCategoryToChatFlow'
import { AddFileAnnotationsToChatMessage1700271021237 } from './1700271021237-AddFileAnnotationsToChatMessage'
export const mysqlMigrations = [
Init1693840429259,
@@ -21,5 +22,6 @@ export const mysqlMigrations = [
AddChatHistory1694658767766,
AddAssistantEntity1699325775451,
AddUsedToolsToChatMessage1699481607341,
AddCategoryToChatFlow1699900910291
AddCategoryToChatFlow1699900910291,
AddFileAnnotationsToChatMessage1700271021237
]
@@ -6,6 +6,6 @@ export class AddUsedToolsToChatMessage1699481607341 implements MigrationInterfac
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "chat_flow" DROP COLUMN "usedTools";`)
await queryRunner.query(`ALTER TABLE "chat_message" DROP COLUMN "usedTools";`)
}
}
@@ -0,0 +1,11 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddFileAnnotationsToChatMessage1700271021237 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "chat_message" ADD COLUMN IF NOT EXISTS "fileAnnotations" TEXT;`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "chat_message" DROP COLUMN "fileAnnotations";`)
}
}
@@ -9,6 +9,7 @@ import { AddChatHistory1694658756136 } from './1694658756136-AddChatHistory'
import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity'
import { AddUsedToolsToChatMessage1699481607341 } from './1699481607341-AddUsedToolsToChatMessage'
import { AddCategoryToChatFlow1699900910291 } from './1699900910291-AddCategoryToChatFlow'
import { AddFileAnnotationsToChatMessage1700271021237 } from './1700271021237-AddFileAnnotationsToChatMessage'
export const postgresMigrations = [
Init1693891895163,
@@ -21,5 +22,6 @@ export const postgresMigrations = [
AddChatHistory1694658756136,
AddAssistantEntity1699325775451,
AddUsedToolsToChatMessage1699481607341,
AddCategoryToChatFlow1699900910291
AddCategoryToChatFlow1699900910291,
AddFileAnnotationsToChatMessage1700271021237
]
@@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddFileAnnotationsToChatMessage1700271021237 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, "usedTools" text, "fileAnnotations" text, "createdDate" datetime NOT NULL DEFAULT (datetime('now')), "chatType" VARCHAR NOT NULL DEFAULT 'INTERNAL', "chatId" VARCHAR NOT NULL, "memoryType" VARCHAR, "sessionId" VARCHAR);`
)
await queryRunner.query(
`INSERT INTO "temp_chat_message" ("id", "role", "chatflowid", "content", "sourceDocuments", "usedTools", "createdDate", "chatType", "chatId", "memoryType", "sessionId") SELECT "id", "role", "chatflowid", "content", "sourceDocuments", "usedTools", "createdDate", "chatType", "chatId", "memoryType", "sessionId" FROM "chat_message";`
)
await queryRunner.query(`DROP TABLE "chat_message";`)
await queryRunner.query(`ALTER TABLE "temp_chat_message" RENAME TO "chat_message";`)
await queryRunner.query(`CREATE INDEX "IDX_e574527322272fd838f4f0f3d3" ON "chat_message" ("chatflowid") ;`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE IF EXISTS "temp_chat_message";`)
await queryRunner.query(`ALTER TABLE "chat_message" DROP COLUMN "fileAnnotations";`)
}
}
@@ -9,6 +9,7 @@ import { AddChatHistory1694657778173 } from './1694657778173-AddChatHistory'
import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity'
import { AddUsedToolsToChatMessage1699481607341 } from './1699481607341-AddUsedToolsToChatMessage'
import { AddCategoryToChatFlow1699900910291 } from './1699900910291-AddCategoryToChatFlow'
import { AddFileAnnotationsToChatMessage1700271021237 } from './1700271021237-AddFileAnnotationsToChatMessage'
export const sqliteMigrations = [
Init1693835579790,
@@ -21,5 +22,6 @@ export const sqliteMigrations = [
AddChatHistory1694657778173,
AddAssistantEntity1699325775451,
AddUsedToolsToChatMessage1699481607341,
AddCategoryToChatFlow1699900910291
AddCategoryToChatFlow1699900910291,
AddFileAnnotationsToChatMessage1700271021237
]