mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
cleanup sqlite migration scripts
This commit is contained in:
+2
-1
@@ -22,7 +22,8 @@
|
|||||||
"lint": "eslint \"**/*.{js,jsx,ts,tsx,json,md}\"",
|
"lint": "eslint \"**/*.{js,jsx,ts,tsx,json,md}\"",
|
||||||
"lint-fix": "yarn lint --fix",
|
"lint-fix": "yarn lint --fix",
|
||||||
"quick": "pretty-quick --staged",
|
"quick": "pretty-quick --staged",
|
||||||
"postinstall": "husky install"
|
"postinstall": "husky install",
|
||||||
|
"migration:create": "yarn typeorm migration:create"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{js,jsx,ts,tsx,json,md}": "eslint --fix"
|
"*.{js,jsx,ts,tsx,json,md}": "eslint --fix"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import path from 'path'
|
|||||||
import { DataSource } from 'typeorm'
|
import { DataSource } from 'typeorm'
|
||||||
import { getUserHome } from './utils'
|
import { getUserHome } from './utils'
|
||||||
import { entities } from './database/entities'
|
import { entities } from './database/entities'
|
||||||
import { InitSqlite1693809869231 } from './database/migrations/1693809869231-initSqlite'
|
import { sqliteMigrations } from './database/migrations/sqlite'
|
||||||
|
|
||||||
let appDataSource: DataSource
|
let appDataSource: DataSource
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ export const init = async (): Promise<void> => {
|
|||||||
synchronize: false,
|
synchronize: false,
|
||||||
migrationsRun: false,
|
migrationsRun: false,
|
||||||
entities: Object.values(entities),
|
entities: Object.values(entities),
|
||||||
migrations: [InitSqlite1693809869231]
|
migrations: sqliteMigrations
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
@@ -58,7 +58,7 @@ export const init = async (): Promise<void> => {
|
|||||||
synchronize: false,
|
synchronize: false,
|
||||||
migrationsRun: false,
|
migrationsRun: false,
|
||||||
entities: Object.values(entities),
|
entities: Object.values(entities),
|
||||||
migrations: [InitSqlite1693809869231]
|
migrations: sqliteMigrations
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-5
@@ -1,27 +1,25 @@
|
|||||||
import { MigrationInterface, QueryRunner } from 'typeorm'
|
import { MigrationInterface, QueryRunner } from 'typeorm'
|
||||||
|
|
||||||
export class InitSqlite1693809869231 implements MigrationInterface {
|
export class Init1693835579790 implements MigrationInterface {
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
console.info('started migration query')
|
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
`CREATE TABLE "chat_flow" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "flowData" text NOT NULL, "deployed" boolean, "isPublic" boolean, "apikeyid" varchar, "chatbotConfig" varchar, "createdDate" datetime NOT NULL DEFAULT (datetime('now')), "updatedDate" datetime NOT NULL DEFAULT (datetime('now')));`
|
`CREATE TABLE "chat_flow" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "flowData" text NOT NULL, "deployed" boolean, "isPublic" boolean, "apikeyid" varchar, "chatbotConfig" varchar, "createdDate" datetime NOT NULL DEFAULT (datetime('now')), "updatedDate" datetime NOT NULL DEFAULT (datetime('now')));`
|
||||||
)
|
)
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
`CREATE TABLE "chat_message" ("id" varchar PRIMARY KEY NOT NULL, "role" varchar NOT NULL, "chatflowid" varchar NOT NULL, "content" text NOT NULL, "sourceDocuments" varchar, "createdDate" datetime NOT NULL DEFAULT (datetime('now')));`
|
`CREATE TABLE "chat_message" ("id" varchar PRIMARY KEY NOT NULL, "role" varchar NOT NULL, "chatflowid" varchar NOT NULL, "content" text NOT NULL, "sourceDocuments" varchar, "createdDate" datetime NOT NULL DEFAULT (datetime('now')));`
|
||||||
)
|
)
|
||||||
await queryRunner.query(`CREATE INDEX "IDX_e574527322272fd838f4f0f3d3" ON "chat_message" ("chatflowid") ;`)
|
await queryRunner.query(`CREATE INDEX "IDX_e574527322272fd838f4f0f3d3" ON "chat_message" ("chatflowid");`)
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
`CREATE TABLE "credential" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "credentialName" varchar NOT NULL, "encryptedData" varchar NOT NULL, "createdDate" datetime NOT NULL DEFAULT (datetime('now')), "updatedDate" datetime NOT NULL DEFAULT (datetime('now')));`
|
`CREATE TABLE "credential" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "credentialName" varchar NOT NULL, "encryptedData" varchar NOT NULL, "createdDate" datetime NOT NULL DEFAULT (datetime('now')), "updatedDate" datetime NOT NULL DEFAULT (datetime('now')));`
|
||||||
)
|
)
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
`CREATE TABLE "tool" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "description" text NOT NULL, "color" varchar NOT NULL, "iconSrc" varchar, "schema" varchar, "func" varchar, "createdDate" datetime NOT NULL DEFAULT (datetime('now')), "updatedDate" datetime NOT NULL DEFAULT (datetime('now')));`
|
`CREATE TABLE "tool" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "description" text NOT NULL, "color" varchar NOT NULL, "iconSrc" varchar, "schema" varchar, "func" varchar, "createdDate" datetime NOT NULL DEFAULT (datetime('now')), "updatedDate" datetime NOT NULL DEFAULT (datetime('now')));`
|
||||||
)
|
)
|
||||||
console.info('Finish migration query')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
await queryRunner.query(`DROP TABLE "chat_flow"`)
|
await queryRunner.query(`DROP TABLE "chat_flow"`)
|
||||||
await queryRunner.query(`DROP INDEX "IDX_chat_messagee574527322272fd838f4f0f3d3"`)
|
await queryRunner.query(`DROP INDEX "IDX_e574527322272fd838f4f0f3d3"`)
|
||||||
await queryRunner.query(`DROP TABLE "chat_message"`)
|
await queryRunner.query(`DROP TABLE "chat_message"`)
|
||||||
await queryRunner.query(`DROP TABLE "credential"`)
|
await queryRunner.query(`DROP TABLE "credential"`)
|
||||||
await queryRunner.query(`DROP TABLE "tool"`)
|
await queryRunner.query(`DROP TABLE "tool"`)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { Init1693835579790 } from './1693835579790-Init'
|
||||||
|
|
||||||
|
export const sqliteMigrations = [Init1693835579790]
|
||||||
@@ -71,10 +71,8 @@ export class App {
|
|||||||
.then(async () => {
|
.then(async () => {
|
||||||
logger.info('📦 [server]: Data Source has been initialized!')
|
logger.info('📦 [server]: Data Source has been initialized!')
|
||||||
|
|
||||||
//Migrations
|
// Run Migrations Scripts
|
||||||
console.info(`start migration`)
|
|
||||||
await this.AppDataSource.runMigrations({ transaction: 'each' })
|
await this.AppDataSource.runMigrations({ transaction: 'each' })
|
||||||
console.info(`finish migration`)
|
|
||||||
|
|
||||||
// Initialize nodes pool
|
// Initialize nodes pool
|
||||||
this.nodesPool = new NodesPool()
|
this.nodesPool = new NodesPool()
|
||||||
|
|||||||
Reference in New Issue
Block a user