Skip to content

Commit 14f4589

Browse files
HenryHengZJ0xi4o
authored andcommitted
Bugfix/Add artifacts migration script to other database types (#3210)
add artifacts migration script to other database types
1 parent 24d164b commit 14f4589

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm'
2+
3+
export class AddArtifactsToChatMessage1726156258465 implements MigrationInterface {
4+
public async up(queryRunner: QueryRunner): Promise<void> {
5+
const columnExists = await queryRunner.hasColumn('chat_message', 'artifacts')
6+
if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_message\` ADD COLUMN \`artifacts\` LONGTEXT;`)
7+
}
8+
9+
public async down(queryRunner: QueryRunner): Promise<void> {
10+
await queryRunner.query(`ALTER TABLE \`chat_message\` DROP COLUMN \`artifacts\`;`)
11+
}
12+
}

packages/server/src/database/migrations/mariadb/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { AddApiKey1720230151480 } from './1720230151480-AddApiKey'
2424
import { AddActionToChatMessage1721078251523 } from './1721078251523-AddActionToChatMessage'
2525
import { LongTextColumn1722301395521 } from './1722301395521-LongTextColumn'
2626
import { AddCustomTemplate1725629836652 } from './1725629836652-AddCustomTemplate'
27+
import { AddArtifactsToChatMessage1726156258465 } from './1726156258465-AddArtifactsToChatMessage'
2728
import { AddFollowUpPrompts1726666318346 } from './1726666318346-AddFollowUpPrompts'
2829

2930
export const mariadbMigrations = [
@@ -53,5 +54,6 @@ export const mariadbMigrations = [
5354
AddActionToChatMessage1721078251523,
5455
LongTextColumn1722301395521,
5556
AddCustomTemplate1725629836652,
57+
AddArtifactsToChatMessage1726156258465,
5658
AddFollowUpPrompts1726666318346
5759
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm'
2+
3+
export class AddArtifactsToChatMessage1726156258465 implements MigrationInterface {
4+
public async up(queryRunner: QueryRunner): Promise<void> {
5+
const columnExists = await queryRunner.hasColumn('chat_message', 'artifacts')
6+
if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_message\` ADD COLUMN \`artifacts\` LONGTEXT;`)
7+
}
8+
9+
public async down(queryRunner: QueryRunner): Promise<void> {
10+
await queryRunner.query(`ALTER TABLE \`chat_message\` DROP COLUMN \`artifacts\`;`)
11+
}
12+
}

packages/server/src/database/migrations/mysql/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { AddApiKey1720230151480 } from './1720230151480-AddApiKey'
2525
import { AddActionToChatMessage1721078251523 } from './1721078251523-AddActionToChatMessage'
2626
import { LongTextColumn1722301395521 } from './1722301395521-LongTextColumn'
2727
import { AddCustomTemplate1725629836652 } from './1725629836652-AddCustomTemplate'
28+
import { AddArtifactsToChatMessage1726156258465 } from './1726156258465-AddArtifactsToChatMessage'
2829
import { AddFollowUpPrompts1726666302024 } from './1726666302024-AddFollowUpPrompts'
2930

3031
export const mysqlMigrations = [
@@ -55,5 +56,6 @@ export const mysqlMigrations = [
5556
AddActionToChatMessage1721078251523,
5657
LongTextColumn1722301395521,
5758
AddCustomTemplate1725629836652,
59+
AddArtifactsToChatMessage1726156258465,
5860
AddFollowUpPrompts1726666302024
5961
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm'
2+
3+
export class AddArtifactsToChatMessage1726156258465 implements MigrationInterface {
4+
public async up(queryRunner: QueryRunner): Promise<void> {
5+
await queryRunner.query(`ALTER TABLE "chat_message" ADD COLUMN IF NOT EXISTS "artifacts" TEXT;`)
6+
}
7+
8+
public async down(queryRunner: QueryRunner): Promise<void> {
9+
await queryRunner.query(`ALTER TABLE "chat_message" DROP COLUMN "artifacts";`)
10+
}
11+
}

packages/server/src/database/migrations/postgres/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { AddTypeToChatFlow1716300000000 } from './1716300000000-AddTypeToChatFlo
2525
import { AddApiKey1720230151480 } from './1720230151480-AddApiKey'
2626
import { AddActionToChatMessage1721078251523 } from './1721078251523-AddActionToChatMessage'
2727
import { AddCustomTemplate1725629836652 } from './1725629836652-AddCustomTemplate'
28+
import { AddArtifactsToChatMessage1726156258465 } from './1726156258465-AddArtifactsToChatMessage'
2829
import { AddFollowUpPrompts1726666309552 } from './1726666309552-AddFollowUpPrompts'
2930

3031
export const postgresMigrations = [
@@ -55,5 +56,6 @@ export const postgresMigrations = [
5556
AddApiKey1720230151480,
5657
AddActionToChatMessage1721078251523,
5758
AddCustomTemplate1725629836652,
59+
AddArtifactsToChatMessage1726156258465,
5860
AddFollowUpPrompts1726666309552
5961
]

0 commit comments

Comments
 (0)