Bugfix/Add artifacts migration script to other database types (#3210)

add artifacts migration script to other database types
This commit is contained in:
Henry Heng 2024-09-17 20:12:27 +01:00 committed by GitHub
parent f5214e7bbc
commit 1c89a3309e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 44 additions and 3 deletions

View File

@ -0,0 +1,12 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddArtifactsToChatMessage1726156258465 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const columnExists = await queryRunner.hasColumn('chat_message', 'artifacts')
if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_message\` ADD COLUMN \`artifacts\` LONGTEXT;`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`chat_message\` DROP COLUMN \`artifacts\`;`)
}
}

View File

@ -24,6 +24,7 @@ import { AddApiKey1720230151480 } from './1720230151480-AddApiKey'
import { AddActionToChatMessage1721078251523 } from './1721078251523-AddActionToChatMessage'
import { LongTextColumn1722301395521 } from './1722301395521-LongTextColumn'
import { AddCustomTemplate1725629836652 } from './1725629836652-AddCustomTemplate'
import { AddArtifactsToChatMessage1726156258465 } from './1726156258465-AddArtifactsToChatMessage'
export const mariadbMigrations = [
Init1693840429259,
@ -51,5 +52,6 @@ export const mariadbMigrations = [
AddApiKey1720230151480,
AddActionToChatMessage1721078251523,
LongTextColumn1722301395521,
AddCustomTemplate1725629836652
AddCustomTemplate1725629836652,
AddArtifactsToChatMessage1726156258465
]

View File

@ -0,0 +1,12 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddArtifactsToChatMessage1726156258465 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const columnExists = await queryRunner.hasColumn('chat_message', 'artifacts')
if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_message\` ADD COLUMN \`artifacts\` LONGTEXT;`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`chat_message\` DROP COLUMN \`artifacts\`;`)
}
}

View File

@ -25,6 +25,7 @@ import { AddApiKey1720230151480 } from './1720230151480-AddApiKey'
import { AddActionToChatMessage1721078251523 } from './1721078251523-AddActionToChatMessage'
import { LongTextColumn1722301395521 } from './1722301395521-LongTextColumn'
import { AddCustomTemplate1725629836652 } from './1725629836652-AddCustomTemplate'
import { AddArtifactsToChatMessage1726156258465 } from './1726156258465-AddArtifactsToChatMessage'
export const mysqlMigrations = [
Init1693840429259,
@ -53,5 +54,6 @@ export const mysqlMigrations = [
AddApiKey1720230151480,
AddActionToChatMessage1721078251523,
LongTextColumn1722301395521,
AddCustomTemplate1725629836652
AddCustomTemplate1725629836652,
AddArtifactsToChatMessage1726156258465
]

View File

@ -0,0 +1,11 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddArtifactsToChatMessage1726156258465 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "chat_message" ADD COLUMN IF NOT EXISTS "artifacts" TEXT;`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "chat_message" DROP COLUMN "artifacts";`)
}
}

View File

@ -25,6 +25,7 @@ import { AddTypeToChatFlow1716300000000 } from './1716300000000-AddTypeToChatFlo
import { AddApiKey1720230151480 } from './1720230151480-AddApiKey'
import { AddActionToChatMessage1721078251523 } from './1721078251523-AddActionToChatMessage'
import { AddCustomTemplate1725629836652 } from './1725629836652-AddCustomTemplate'
import { AddArtifactsToChatMessage1726156258465 } from './1726156258465-AddArtifactsToChatMessage'
export const postgresMigrations = [
Init1693891895163,
@ -53,5 +54,6 @@ export const postgresMigrations = [
AddVectorStoreConfigToDocStore1715861032479,
AddApiKey1720230151480,
AddActionToChatMessage1721078251523,
AddCustomTemplate1725629836652
AddCustomTemplate1725629836652,
AddArtifactsToChatMessage1726156258465
]