mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
init migration poc
This commit is contained in:
@@ -1,26 +1,24 @@
|
||||
import 'reflect-metadata'
|
||||
import path from 'path'
|
||||
import { DataSource } from 'typeorm'
|
||||
import { ChatFlow } from './entity/ChatFlow'
|
||||
import { ChatMessage } from './entity/ChatMessage'
|
||||
import { Credential } from './entity/Credential'
|
||||
import { Tool } from './entity/Tool'
|
||||
import { getUserHome } from './utils'
|
||||
import { entities } from './database/entities'
|
||||
import { InitSqlite1693809869231 } from './database/migrations/1693809869231-initSqlite'
|
||||
|
||||
let appDataSource: DataSource
|
||||
|
||||
export const init = async (): Promise<void> => {
|
||||
let homePath
|
||||
const synchronize = process.env.OVERRIDE_DATABASE === 'false' ? false : true
|
||||
switch (process.env.DATABASE_TYPE) {
|
||||
case 'sqlite':
|
||||
homePath = process.env.DATABASE_PATH ?? path.join(getUserHome(), '.flowise')
|
||||
appDataSource = new DataSource({
|
||||
type: 'sqlite',
|
||||
database: path.resolve(homePath, 'database.sqlite'),
|
||||
synchronize,
|
||||
entities: [ChatFlow, ChatMessage, Tool, Credential],
|
||||
migrations: []
|
||||
synchronize: false,
|
||||
migrationsRun: false,
|
||||
entities: Object.values(entities),
|
||||
migrations: [InitSqlite1693809869231]
|
||||
})
|
||||
break
|
||||
case 'mysql':
|
||||
@@ -32,8 +30,9 @@ export const init = async (): Promise<void> => {
|
||||
password: process.env.DATABASE_PASSWORD,
|
||||
database: process.env.DATABASE_NAME,
|
||||
charset: 'utf8mb4',
|
||||
synchronize,
|
||||
entities: [ChatFlow, ChatMessage, Tool, Credential],
|
||||
synchronize: false,
|
||||
migrationsRun: false,
|
||||
entities: Object.values(entities),
|
||||
migrations: []
|
||||
})
|
||||
break
|
||||
@@ -45,8 +44,9 @@ export const init = async (): Promise<void> => {
|
||||
username: process.env.DATABASE_USER,
|
||||
password: process.env.DATABASE_PASSWORD,
|
||||
database: process.env.DATABASE_NAME,
|
||||
synchronize,
|
||||
entities: [ChatFlow, ChatMessage, Tool, Credential],
|
||||
synchronize: false,
|
||||
migrationsRun: false,
|
||||
entities: Object.values(entities),
|
||||
migrations: []
|
||||
})
|
||||
break
|
||||
@@ -55,9 +55,10 @@ export const init = async (): Promise<void> => {
|
||||
appDataSource = new DataSource({
|
||||
type: 'sqlite',
|
||||
database: path.resolve(homePath, 'database.sqlite'),
|
||||
synchronize,
|
||||
entities: [ChatFlow, ChatMessage, Tool, Credential],
|
||||
migrations: []
|
||||
synchronize: false,
|
||||
migrationsRun: false,
|
||||
entities: Object.values(entities),
|
||||
migrations: [InitSqlite1693809869231]
|
||||
})
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user