From 3f934207171a8a7cc1188245ed5689eca160f66d Mon Sep 17 00:00:00 2001 From: geekgeekrun Date: Wed, 20 Nov 2024 00:38:35 +0800 Subject: [PATCH] set encryptCompanyId in BossInfo nullable --- packages/sqlite-plugin/src/entity/BossInfo.ts | 4 ++- packages/sqlite-plugin/src/index.ts | 4 ++- .../1732032381304-UpdateBossInfoTable.ts | 35 +++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 packages/sqlite-plugin/src/migrations/1732032381304-UpdateBossInfoTable.ts diff --git a/packages/sqlite-plugin/src/entity/BossInfo.ts b/packages/sqlite-plugin/src/entity/BossInfo.ts index f7eea6c..1971ff2 100644 --- a/packages/sqlite-plugin/src/entity/BossInfo.ts +++ b/packages/sqlite-plugin/src/entity/BossInfo.ts @@ -6,7 +6,9 @@ export class BossInfo { @PrimaryColumn() encryptBossId: string; - @Column() + @Column({ + nullable: true + }) encryptCompanyId: string; @Column() diff --git a/packages/sqlite-plugin/src/index.ts b/packages/sqlite-plugin/src/index.ts index 1a554e0..07cb6fb 100644 --- a/packages/sqlite-plugin/src/index.ts +++ b/packages/sqlite-plugin/src/index.ts @@ -25,6 +25,7 @@ import * as cliHighlight from 'cli-highlight'; import { saveChatStartupRecord, saveJobInfoFromRecommendPage, saveMarkAsNotSuitRecord } from "./handlers"; import { UpdateChatStartupLogTable1729182577167 } from "./migrations/1729182577167-UpdateChatStartupLogTable"; import minimist from 'minimist' +import { UpdateBossInfoTable1732032381304 } from "./migrations/1732032381304-UpdateBossInfoTable"; Boolean(cliHighlight); @@ -57,7 +58,8 @@ export function initDb(dbFilePath) { ChatMessageRecord, ], migrations: [ - UpdateChatStartupLogTable1729182577167 + UpdateChatStartupLogTable1729182577167, + UpdateBossInfoTable1732032381304 ], migrationsRun: true }); diff --git a/packages/sqlite-plugin/src/migrations/1732032381304-UpdateBossInfoTable.ts b/packages/sqlite-plugin/src/migrations/1732032381304-UpdateBossInfoTable.ts new file mode 100644 index 0000000..200bda9 --- /dev/null +++ b/packages/sqlite-plugin/src/migrations/1732032381304-UpdateBossInfoTable.ts @@ -0,0 +1,35 @@ +import { MigrationInterface, QueryRunner, TableColumn } from "typeorm"; + +const viewNames = [ + "v_boss_library", + "v_chat_startup_log", + "v_company_library", + "v_job_library", + "v_mark_as_not_suit_log" +]; + +export class UpdateBossInfoTable1732032381304 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + for (const viewName of viewNames) { + await queryRunner.query(`DROP VIEW IF EXISTS "${viewName}"`); + } + if (await queryRunner.hasTable("boss_info")) { + if (await queryRunner.hasColumn("boss_info", "encryptCompanyId")) { + await queryRunner.changeColumn( + 'boss_info', + 'encryptCompanyId', + new TableColumn({ + name: 'encryptCompanyId', + type: 'varchar', + isNullable: true + }) + ) + debugger + } + } + } + + public async down(queryRunner: QueryRunner): Promise { + } + +}