mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 23:01:09 +03:00
add postgresMigrations
This commit is contained in:
@@ -5,6 +5,7 @@ import { getUserHome } from './utils'
|
|||||||
import { entities } from './database/entities'
|
import { entities } from './database/entities'
|
||||||
import { sqliteMigrations } from './database/migrations/sqlite'
|
import { sqliteMigrations } from './database/migrations/sqlite'
|
||||||
import { mysqlMigrations } from './database/migrations/mysql'
|
import { mysqlMigrations } from './database/migrations/mysql'
|
||||||
|
import { postgresMigrations } from './database/migrations/postgres'
|
||||||
|
|
||||||
let appDataSource: DataSource
|
let appDataSource: DataSource
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ export const init = async (): Promise<void> => {
|
|||||||
synchronize: false,
|
synchronize: false,
|
||||||
migrationsRun: false,
|
migrationsRun: false,
|
||||||
entities: Object.values(entities),
|
entities: Object.values(entities),
|
||||||
migrations: []
|
migrations: postgresMigrations
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from 'typeorm'
|
||||||
|
|
||||||
|
export class Init1693891895163 implements MigrationInterface {
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TABLE chat_flow (
|
||||||
|
id uuid NOT NULL DEFAULT uuid_generate_v4(),
|
||||||
|
"name" varchar NOT NULL,
|
||||||
|
"flowData" text NOT NULL,
|
||||||
|
deployed bool NULL,
|
||||||
|
"isPublic" bool NULL,
|
||||||
|
apikeyid varchar NULL,
|
||||||
|
"chatbotConfig" text NULL,
|
||||||
|
"createdDate" timestamp NOT NULL DEFAULT now(),
|
||||||
|
"updatedDate" timestamp NOT NULL DEFAULT now(),
|
||||||
|
CONSTRAINT "PK_3c7cea7d047ac4b91764574cdbf" PRIMARY KEY (id)
|
||||||
|
);`
|
||||||
|
)
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TABLE chat_message (
|
||||||
|
id uuid NOT NULL DEFAULT uuid_generate_v4(),
|
||||||
|
"role" varchar NOT NULL,
|
||||||
|
chatflowid varchar NOT NULL,
|
||||||
|
"content" text NOT NULL,
|
||||||
|
"sourceDocuments" text NULL,
|
||||||
|
"createdDate" timestamp NOT NULL DEFAULT now(),
|
||||||
|
CONSTRAINT "PK_3cc0d85193aade457d3077dd06b" PRIMARY KEY (id)
|
||||||
|
);`
|
||||||
|
)
|
||||||
|
await queryRunner.query(`CREATE INDEX "IDX_e574527322272fd838f4f0f3d3" ON chat_message USING btree (chatflowid);`)
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TABLE credential (
|
||||||
|
id uuid NOT NULL DEFAULT uuid_generate_v4(),
|
||||||
|
"name" varchar NOT NULL,
|
||||||
|
"credentialName" varchar NOT NULL,
|
||||||
|
"encryptedData" text NOT NULL,
|
||||||
|
"createdDate" timestamp NOT NULL DEFAULT now(),
|
||||||
|
"updatedDate" timestamp NOT NULL DEFAULT now(),
|
||||||
|
CONSTRAINT "PK_3a5169bcd3d5463cefeec78be82" PRIMARY KEY (id)
|
||||||
|
);`
|
||||||
|
)
|
||||||
|
await queryRunner.query(
|
||||||
|
`CREATE TABLE tool (
|
||||||
|
id uuid NOT NULL DEFAULT uuid_generate_v4(),
|
||||||
|
"name" varchar NOT NULL,
|
||||||
|
description text NOT NULL,
|
||||||
|
color varchar NOT NULL,
|
||||||
|
"iconSrc" varchar NULL,
|
||||||
|
"schema" text NULL,
|
||||||
|
func text NULL,
|
||||||
|
"createdDate" timestamp NOT NULL DEFAULT now(),
|
||||||
|
"updatedDate" timestamp NOT NULL DEFAULT now(),
|
||||||
|
CONSTRAINT "PK_3bf5b1016a384916073184f99b7" PRIMARY KEY (id)
|
||||||
|
);`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
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 { Init1693891895163 } from './1693891895163-Init'
|
||||||
|
|
||||||
|
export const postgresMigrations = [Init1693891895163]
|
||||||
Reference in New Issue
Block a user