add mysqlMigrations
This commit is contained in:
parent
02924f96c8
commit
17c2309454
|
|
@ -4,6 +4,7 @@ import { DataSource } from 'typeorm'
|
|||
import { getUserHome } from './utils'
|
||||
import { entities } from './database/entities'
|
||||
import { sqliteMigrations } from './database/migrations/sqlite'
|
||||
import { mysqlMigrations } from './database/migrations/mysql'
|
||||
|
||||
let appDataSource: DataSource
|
||||
|
||||
|
|
@ -33,7 +34,7 @@ export const init = async (): Promise<void> => {
|
|||
synchronize: false,
|
||||
migrationsRun: false,
|
||||
entities: Object.values(entities),
|
||||
migrations: []
|
||||
migrations: mysqlMigrations
|
||||
})
|
||||
break
|
||||
case 'postgres':
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm'
|
||||
|
||||
export class Init1693840429259 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE \`chat_flow\` (
|
||||
\`id\` varchar(36) NOT NULL,
|
||||
\`name\` varchar(255) NOT NULL,
|
||||
\`flowData\` text NOT NULL,
|
||||
\`deployed\` tinyint DEFAULT NULL,
|
||||
\`isPublic\` tinyint DEFAULT NULL,
|
||||
\`apikeyid\` varchar(255) DEFAULT NULL,
|
||||
\`chatbotConfig\` text,
|
||||
\`createdDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
\`updatedDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||
PRIMARY KEY (\`id\`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;`
|
||||
)
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE \`chat_message\` (
|
||||
\`id\` varchar(36) NOT NULL,
|
||||
\`role\` varchar(255) NOT NULL,
|
||||
\`chatflowid\` varchar(255) NOT NULL,
|
||||
\`content\` text NOT NULL,
|
||||
\`sourceDocuments\` text,
|
||||
\`createdDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
PRIMARY KEY (\`id\`),
|
||||
KEY \`IDX_e574527322272fd838f4f0f3d3\` (\`chatflowid\`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;`
|
||||
)
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE \`credential\` (
|
||||
\`id\` varchar(36) NOT NULL,
|
||||
\`name\` varchar(255) NOT NULL,
|
||||
\`credentialName\` varchar(255) NOT NULL,
|
||||
\`encryptedData\` text NOT NULL,
|
||||
\`createdDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
\`updatedDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||
PRIMARY KEY (\`id\`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;`
|
||||
)
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE \`tool\` (
|
||||
\`id\` varchar(36) NOT NULL,
|
||||
\`name\` varchar(255) NOT NULL,
|
||||
\`description\` text NOT NULL,
|
||||
\`color\` varchar(255) NOT NULL,
|
||||
\`iconSrc\` varchar(255) DEFAULT NULL,
|
||||
\`schema\` text,
|
||||
\`func\` text,
|
||||
\`createdDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||||
\`updatedDate\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||
PRIMARY KEY (\`id\`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;`
|
||||
)
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE "chat_flow"`)
|
||||
await queryRunner.query(`DROP TABLE "chat_message"`)
|
||||
await queryRunner.query(`DROP TABLE "credential"`)
|
||||
await queryRunner.query(`DROP TABLE "tool"`)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import { Init1693840429259 } from './1693840429259-Init'
|
||||
|
||||
export const mysqlMigrations = [Init1693840429259]
|
||||
Loading…
Reference in New Issue