From b688f962363e2f8aefcbff51055ee79b49532c20 Mon Sep 17 00:00:00 2001 From: chungyau97 Date: Tue, 5 Sep 2023 00:55:39 +0800 Subject: [PATCH] update sqlite init query --- .../migrations/mysql/1693840429259-Init.ts | 8 ++++---- .../migrations/sqlite/1693835579790-Init.ts | 19 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/packages/server/src/database/migrations/mysql/1693840429259-Init.ts b/packages/server/src/database/migrations/mysql/1693840429259-Init.ts index 8d0346803..6ae611dcb 100644 --- a/packages/server/src/database/migrations/mysql/1693840429259-Init.ts +++ b/packages/server/src/database/migrations/mysql/1693840429259-Init.ts @@ -56,9 +56,9 @@ export class Init1693840429259 implements MigrationInterface { } public async down(queryRunner: QueryRunner): Promise { - 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"`) + 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`) } } diff --git a/packages/server/src/database/migrations/sqlite/1693835579790-Init.ts b/packages/server/src/database/migrations/sqlite/1693835579790-Init.ts index 2ae72b63b..2c1998814 100644 --- a/packages/server/src/database/migrations/sqlite/1693835579790-Init.ts +++ b/packages/server/src/database/migrations/sqlite/1693835579790-Init.ts @@ -3,25 +3,24 @@ import { MigrationInterface, QueryRunner } from 'typeorm' export class Init1693835579790 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { 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" text, "createdDate" datetime NOT NULL DEFAULT (datetime('now')), "updatedDate" datetime NOT NULL DEFAULT (datetime('now')));` ) 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" text, "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( - `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" text NOT NULL, "createdDate" datetime NOT NULL DEFAULT (datetime('now')), "updatedDate" datetime NOT NULL DEFAULT (datetime('now')));` ) 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" text, "func" text, "createdDate" datetime NOT NULL DEFAULT (datetime('now')), "updatedDate" datetime NOT NULL DEFAULT (datetime('now')));` ) } public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DROP TABLE "chat_flow"`) - await queryRunner.query(`DROP INDEX "IDX_e574527322272fd838f4f0f3d3"`) - await queryRunner.query(`DROP TABLE "chat_message"`) - await queryRunner.query(`DROP TABLE "credential"`) - await queryRunner.query(`DROP TABLE "tool"`) + 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`) } }