add sqlite modify tool

This commit is contained in:
chungyau97
2023-09-05 22:41:28 +08:00
parent 1c1b057512
commit aa1122641c
4 changed files with 24 additions and 4 deletions
@@ -19,10 +19,10 @@ export class Tool implements ITool {
@Column({ nullable: true })
iconSrc?: string
@Column({ nullable: true })
@Column({ nullable: true, type: 'text' })
schema?: string
@Column({ nullable: true })
@Column({ nullable: true, type: 'text' })
func?: string
@CreateDateColumn()
@@ -13,6 +13,6 @@ export class ModifyCredential1693923551694 implements MigrationInterface {
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE credential`)
await queryRunner.query(`DROP TABLE temp_credential`)
}
}
@@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class ModifyTool1693924207475 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "temp_tool" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "description" text NOT NULL, "color" varchar NOT NULL, "iconSrc" varchar, "schema" text, "func" text, "createdDate" datetime NOT NULL DEFAULT (datetime('now')), "updatedDate" datetime NOT NULL DEFAULT (datetime('now')));`
)
await queryRunner.query(
`INSERT INTO "temp_tool" ("id", "name", "description", "color", "iconSrc", "schema", "func", "createdDate", "updatedDate") SELECT "id", "name", "description", "color", "iconSrc", "schema", "func", "createdDate", "updatedDate" FROM "tool";`
)
await queryRunner.query(`DROP TABLE tool;`)
await queryRunner.query(`ALTER TABLE temp_tool RENAME TO tool;`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE temp_tool`)
}
}
@@ -2,10 +2,12 @@ import { Init1693835579790 } from './1693835579790-Init'
import { ModifyChatFlow1693920824108 } from './1693920824108-ModifyChatFlow'
import { ModifyChatMessage1693921865247 } from './1693921865247-ModifyChatMessage'
import { ModifyCredential1693923551694 } from './1693923551694-ModifyCredential'
import { ModifyTool1693924207475 } from './1693924207475-ModifyTool'
export const sqliteMigrations = [
Init1693835579790,
ModifyChatFlow1693920824108,
ModifyChatMessage1693921865247,
ModifyCredential1693923551694
ModifyCredential1693923551694,
ModifyTool1693924207475
]