Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(database): add copilot table migrate script #1514

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/database/database.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { saveScriptName1688449795669 } from './migration/1688449795669-saveScrip
import { jsonHighlight1691071794840 } from './migration/1691071794840-jsonHighlight'
import { ALPNProtocols1691817588169 } from './migration/1691817588169-ALPNProtocols'
import { aiSettings1701761407723 } from './migration/1701761407723-aiSettings'
import { aiTables1701936842016 } from './migration/1701936842016-aiTables'

const STORE_PATH = getAppDataPath('MQTTX')
try {
Expand Down Expand Up @@ -86,6 +87,7 @@ const ORMConfig = {
jsonHighlight1691071794840,
ALPNProtocols1691817588169,
aiSettings1701761407723,
aiTables1701936842016,
],
migrationsTableName: 'temp_migration_table',
entities: [
Expand Down
22 changes: 22 additions & 0 deletions src/database/migration/1701936842016-aiTables.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { MigrationInterface, QueryRunner } from 'typeorm'

export class aiTables1701936842016 implements MigrationInterface {
name = 'aiTables1701936842016'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
CREATE TABLE "CopilotEntity" (
"id" varchar PRIMARY KEY NOT NULL,
"role" varchar NOT NULL,
"content" text NOT NULL,
"createAt" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP)
)
`)
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
DROP TABLE "CopilotEntity"
`)
}
}
Loading