From 1aa51944a6a2077ad80e6d2a4b089cdc4aee5905 Mon Sep 17 00:00:00 2001 From: Rupenieks Date: Wed, 22 Apr 2020 15:52:15 +0200 Subject: [PATCH 1/8] Initial migration files for each DB --- packages/cli/ormconfig.ts | 68 +++++++++++++++++++ packages/cli/package.json | 5 +- .../1587563438936-InitialMigration.ts | 11 +++ .../1587563497207-InitialMigration.ts | 11 +++ .../1587563465704-InitialMigration.ts | 11 +++ .../1587563481290-InitialMigration.ts | 11 +++ 6 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 packages/cli/ormconfig.ts create mode 100644 packages/cli/src/databases/mongodb/Migrations/1587563438936-InitialMigration.ts create mode 100644 packages/cli/src/databases/mysqldb/Migrations/1587563497207-InitialMigration.ts create mode 100644 packages/cli/src/databases/postgresdb/Migrations/1587563465704-InitialMigration.ts create mode 100644 packages/cli/src/databases/sqlite/Migrations/1587563481290-InitialMigration.ts diff --git a/packages/cli/ormconfig.ts b/packages/cli/ormconfig.ts new file mode 100644 index 0000000000..34066ed8af --- /dev/null +++ b/packages/cli/ormconfig.ts @@ -0,0 +1,68 @@ +import {MongoDb, SQLite, MySQLDb, PostgresDb} from './src/databases/index'; + +module.exports = [ + { + "type": "mongodb", + "logging": false, + "entities": Object.values(MongoDb), + "migrations": [ + "./src/databases/mongodb/Migrations/**/*.ts" + ], + "subscribers": [ + "src/subscriber/**/*.ts" + ], + "cli": { + "entitiesDir": "./src/databases/mongodb", + "migrationsDir": "./src/databases/mongodb/Migrations", + "subscribersDir": "./src/databases/mongodb/Subscribers" + } + }, + { + "type": "postgres", + "logging": false, + "entities": Object.values(PostgresDb), + "migrations": [ + "./src/databases/postgresdb/Migrations/**/*.ts" + ], + "subscribers": [ + "src/subscriber/**/*.ts" + ], + "cli": { + "entitiesDir": "./src/databases/postgresdb", + "migrationsDir": "./src/databases/postgresdb/Migrations", + "subscribersDir": "./src/databases/postgresdb/Subscribers" + } + }, + { + "type": "sqlite", + "logging": false, + "entities": Object.values(SQLite), + "migrations": [ + "./src/databases/sqlite/Migrations/**/*.ts" + ], + "subscribers": [ + "src/subscriber/**/*.ts" + ], + "cli": { + "entitiesDir": "./src/databases/sqlite", + "migrationsDir": "./src/databases/sqlite/Migrations", + "subscribersDir": "./src/databases/sqlite/Subscribers" + } + }, + { + "type": "mysql", + "logging": false, + "entities": Object.values(MySQLDb), + "migrations": [ + "./src/databases/mysqldb/Migrations/**/*.ts" + ], + "subscribers": [ + "src/subscriber/**/*.ts" + ], + "cli": { + "entitiesDir": "./src/databases/mysqldb", + "migrationsDir": "./src/databases/mysqldb/Migrations", + "subscribersDir": "./src/databases/mysqldb/Subscribers" + } + }, +]; \ No newline at end of file diff --git a/packages/cli/package.json b/packages/cli/package.json index ab93ea967f..ee5933b25f 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -28,7 +28,8 @@ "start:windows": "cd bin && n8n", "test": "jest", "tslint": "tslint -p tsconfig.json -c tslint.json", - "watch": "tsc --watch" + "watch": "tsc --watch", + "typeorm": "ts-node ./node_modules/typeorm/cli.js" }, "bin": { "n8n": "./bin/n8n" @@ -104,7 +105,7 @@ "request-promise-native": "^1.0.7", "sqlite3": "^4.0.6", "sse-channel": "^3.1.1", - "typeorm": "^0.2.16" + "typeorm": "^0.2.24" }, "jest": { "transform": { diff --git a/packages/cli/src/databases/mongodb/Migrations/1587563438936-InitialMigration.ts b/packages/cli/src/databases/mongodb/Migrations/1587563438936-InitialMigration.ts new file mode 100644 index 0000000000..f26191c69a --- /dev/null +++ b/packages/cli/src/databases/mongodb/Migrations/1587563438936-InitialMigration.ts @@ -0,0 +1,11 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class InitialMigration1587563438936 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + } + + public async down(queryRunner: QueryRunner): Promise { + } + +} diff --git a/packages/cli/src/databases/mysqldb/Migrations/1587563497207-InitialMigration.ts b/packages/cli/src/databases/mysqldb/Migrations/1587563497207-InitialMigration.ts new file mode 100644 index 0000000000..1a083bd65a --- /dev/null +++ b/packages/cli/src/databases/mysqldb/Migrations/1587563497207-InitialMigration.ts @@ -0,0 +1,11 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class InitialMigration1587563497207 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + } + + public async down(queryRunner: QueryRunner): Promise { + } + +} diff --git a/packages/cli/src/databases/postgresdb/Migrations/1587563465704-InitialMigration.ts b/packages/cli/src/databases/postgresdb/Migrations/1587563465704-InitialMigration.ts new file mode 100644 index 0000000000..bcab733bf6 --- /dev/null +++ b/packages/cli/src/databases/postgresdb/Migrations/1587563465704-InitialMigration.ts @@ -0,0 +1,11 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class InitialMigration1587563465704 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + } + + public async down(queryRunner: QueryRunner): Promise { + } + +} diff --git a/packages/cli/src/databases/sqlite/Migrations/1587563481290-InitialMigration.ts b/packages/cli/src/databases/sqlite/Migrations/1587563481290-InitialMigration.ts new file mode 100644 index 0000000000..20d30f068d --- /dev/null +++ b/packages/cli/src/databases/sqlite/Migrations/1587563481290-InitialMigration.ts @@ -0,0 +1,11 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class InitialMigration1587563481290 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + } + + public async down(queryRunner: QueryRunner): Promise { + } + +} From 07c69f5ade15ce0424fe9490cf372f32d883d7bb Mon Sep 17 00:00:00 2001 From: Rupenieks Date: Wed, 22 Apr 2020 16:03:50 +0200 Subject: [PATCH 2/8] Migration settings --- packages/cli/src/Db.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/Db.ts b/packages/cli/src/Db.ts index ed24baabd2..9d9998cfbc 100644 --- a/packages/cli/src/Db.ts +++ b/packages/cli/src/Db.ts @@ -45,6 +45,8 @@ export async function init(synchronize?: boolean): Promise entityPrefix: await GenericHelpers.getConfigValue('database.tablePrefix') as string, url: await GenericHelpers.getConfigValue('database.mongodb.connectionUrl') as string, useNewUrlParser: true, + migrations: ['./databases/mongodb/Migrations/*.ts'], + migrationsRun: true }; break; @@ -60,6 +62,8 @@ export async function init(synchronize?: boolean): Promise port: await GenericHelpers.getConfigValue('database.postgresdb.port') as number, username: await GenericHelpers.getConfigValue('database.postgresdb.user') as string, schema: await GenericHelpers.getConfigValue('database.postgresdb.schema') as string, + migrations: ['./databases/postgresdb/Migrations/*.ts'], + migrationsRun: true }; break; @@ -75,6 +79,8 @@ export async function init(synchronize?: boolean): Promise password: await GenericHelpers.getConfigValue('database.mysqldb.password') as string, port: await GenericHelpers.getConfigValue('database.mysqldb.port') as number, username: await GenericHelpers.getConfigValue('database.mysqldb.user') as string, + migrations: ['./databases/mysqldb/Migrations/*.ts'], + migrationsRun: true }; break; @@ -85,6 +91,8 @@ export async function init(synchronize?: boolean): Promise type: 'sqlite', database: path.join(n8nFolder, 'database.sqlite'), entityPrefix: await GenericHelpers.getConfigValue('database.tablePrefix') as string, + migrations: ['./databases/sqlite/Migrations/*.ts'], + migrationsRun: true }; break; @@ -94,7 +102,7 @@ export async function init(synchronize?: boolean): Promise Object.assign(connectionOptions, { entities: Object.values(entities), - synchronize: synchronize === true || process.env['NODE_ENV'] !== 'production', + synchronize: false,//synchronize === true || process.env['NODE_ENV'] !== 'production', logging: false }); From daeafe68f37491131d492ced8891eee2bc83dcae Mon Sep 17 00:00:00 2001 From: Rupenieks Date: Mon, 27 Apr 2020 12:46:09 +0200 Subject: [PATCH 3/8] init migration test files, ormconfig --- packages/cli/commands/start.ts | 6 +- packages/cli/ormconfig.ts | 49 ++++++++------ packages/cli/package.json | 1 + packages/cli/src/Db.ts | 64 ++++++++----------- .../1587669153312-InitialMigration.ts | 22 +++++++ packages/cli/src/databases/sqlite/index.ts | 1 + .../1587628010571-InitialMigration.ts | 23 +++++++ 7 files changed, 107 insertions(+), 59 deletions(-) create mode 100644 packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts create mode 100644 packages/cli/src/databases/sqlite/migrations/1587628010571-InitialMigration.ts diff --git a/packages/cli/commands/start.ts b/packages/cli/commands/start.ts index 4e2efaacfd..00789b9b43 100644 --- a/packages/cli/commands/start.ts +++ b/packages/cli/commands/start.ts @@ -115,7 +115,11 @@ export class Start extends Command { await credentialTypes.init(loadNodesAndCredentials.credentialTypes); // Wait till the database is ready - await startDbInitPromise; + let dbReady = await startDbInitPromise; + + if(!dbReady){ + throw new Error("DB did not initialize."); + } if (flags.tunnel === true) { this.log('\nWaiting for tunnel ...'); diff --git a/packages/cli/ormconfig.ts b/packages/cli/ormconfig.ts index 34066ed8af..e35fb7e17f 100644 --- a/packages/cli/ormconfig.ts +++ b/packages/cli/ormconfig.ts @@ -2,6 +2,25 @@ import {MongoDb, SQLite, MySQLDb, PostgresDb} from './src/databases/index'; module.exports = [ { + "name": "sqlite", + "type": "sqlite", + "logging": true, + "entities": Object.values(SQLite), + "database": "C:\Users\Ronald\.n8n\database.sqlite", + "migrations": [ + "./src/databases/sqlite/migrations/*.ts" + ], + "subscribers": [ + "./src/databases/sqlite/subscribers/*.ts" + ], + "cli": { + "entitiesDir": "./src/databases/sqlite", + "migrationsDir": "./src/databases/sqlite/migrations", + "subscribersDir": "./src/databases/sqlite/subscribers" + } + }, + { + "name": "mongodb", "type": "mongodb", "logging": false, "entities": Object.values(MongoDb), @@ -18,38 +37,30 @@ module.exports = [ } }, { + "name": "postgres", "type": "postgres", "logging": false, + "host": "localhost", + "username": "postgres", + "password": "docker", + "port": 5432, + "database": "postgres", + "schema": "public", "entities": Object.values(PostgresDb), "migrations": [ - "./src/databases/postgresdb/Migrations/**/*.ts" + "./src/databases/postgresdb/migrations/*.ts" ], "subscribers": [ "src/subscriber/**/*.ts" ], "cli": { "entitiesDir": "./src/databases/postgresdb", - "migrationsDir": "./src/databases/postgresdb/Migrations", - "subscribersDir": "./src/databases/postgresdb/Subscribers" - } - }, - { - "type": "sqlite", - "logging": false, - "entities": Object.values(SQLite), - "migrations": [ - "./src/databases/sqlite/Migrations/**/*.ts" - ], - "subscribers": [ - "src/subscriber/**/*.ts" - ], - "cli": { - "entitiesDir": "./src/databases/sqlite", - "migrationsDir": "./src/databases/sqlite/Migrations", - "subscribersDir": "./src/databases/sqlite/Subscribers" + "migrationsDir": "./src/databases/postgresdb/migrations", + "subscribersDir": "./src/databases/postgresdb/subscribers" } }, { + "name": "mysql", "type": "mysql", "logging": false, "entities": Object.values(MySQLDb), diff --git a/packages/cli/package.json b/packages/cli/package.json index ee5933b25f..e0f9818a78 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -105,6 +105,7 @@ "request-promise-native": "^1.0.7", "sqlite3": "^4.0.6", "sse-channel": "^3.1.1", + "ts-node": "^8.9.1", "typeorm": "^0.2.24" }, "jest": { diff --git a/packages/cli/src/Db.ts b/packages/cli/src/Db.ts index 9d9998cfbc..29c94508aa 100644 --- a/packages/cli/src/Db.ts +++ b/packages/cli/src/Db.ts @@ -12,6 +12,7 @@ import { ConnectionOptions, createConnection, getRepository, + Connection, } from 'typeorm'; import { @@ -29,12 +30,13 @@ export let collections: IDatabaseCollections = { import * as path from 'path'; -export async function init(synchronize?: boolean): Promise { +export async function init(synchronize?: boolean): Promise { const dbType = await GenericHelpers.getConfigValue('database.type') as DatabaseType; const n8nFolder = UserSettings.getUserN8nFolderPath(); let entities; let connectionOptions: ConnectionOptions; + let connection; let dbNotExistError: string | undefined; switch (dbType) { @@ -45,8 +47,7 @@ export async function init(synchronize?: boolean): Promise entityPrefix: await GenericHelpers.getConfigValue('database.tablePrefix') as string, url: await GenericHelpers.getConfigValue('database.mongodb.connectionUrl') as string, useNewUrlParser: true, - migrations: ['./databases/mongodb/Migrations/*.ts'], - migrationsRun: true + migrations: ['./databases/mongodb/migrations/*.js'], }; break; @@ -62,8 +63,7 @@ export async function init(synchronize?: boolean): Promise port: await GenericHelpers.getConfigValue('database.postgresdb.port') as number, username: await GenericHelpers.getConfigValue('database.postgresdb.user') as string, schema: await GenericHelpers.getConfigValue('database.postgresdb.schema') as string, - migrations: ['./databases/postgresdb/Migrations/*.ts'], - migrationsRun: true + migrations: ['./databases/postgresdb/migrations/*.js'] }; break; @@ -79,8 +79,7 @@ export async function init(synchronize?: boolean): Promise password: await GenericHelpers.getConfigValue('database.mysqldb.password') as string, port: await GenericHelpers.getConfigValue('database.mysqldb.port') as number, username: await GenericHelpers.getConfigValue('database.mysqldb.user') as string, - migrations: ['./databases/mysqldb/Migrations/*.ts'], - migrationsRun: true + migrations: ['./databases/mysqldb/migrations/*.js'] }; break; @@ -91,8 +90,7 @@ export async function init(synchronize?: boolean): Promise type: 'sqlite', database: path.join(n8nFolder, 'database.sqlite'), entityPrefix: await GenericHelpers.getConfigValue('database.tablePrefix') as string, - migrations: ['./databases/sqlite/Migrations/*.ts'], - migrationsRun: true + migrations: ['./databases/sqlite/migrations/*.js'], }; break; @@ -103,37 +101,25 @@ export async function init(synchronize?: boolean): Promise Object.assign(connectionOptions, { entities: Object.values(entities), synchronize: false,//synchronize === true || process.env['NODE_ENV'] !== 'production', - logging: false + logging: true, + migrationsRun: true }); - const connection = await createConnection(connectionOptions); - - // TODO: Fix that properly - // @ts-ignore - collections.Credentials = getRepository(entities.CredentialsEntity); - // @ts-ignore - collections.Execution = getRepository(entities.ExecutionEntity); - // @ts-ignore - collections.Workflow = getRepository(entities.WorkflowEntity); - - // Make sure that database did already get initialized - try { - // Try a simple query, if it fails it is normally a sign that - // database did not get initialized - await collections.Workflow!.findOne({ id: 1 }); - } catch (error) { - // If query errors and the problem is that the database does not exist - // run the init again with "synchronize: true" - if (dbNotExistError !== undefined && error.message.includes(dbNotExistError)) { - // Disconnect before we try to connect again - if (connection.isConnected) { - await connection.close(); - } - - return init(true); - } - throw error; + for(let i = 0; i < 1000; i++){ + console.log(connectionOptions); } - return collections; -} + try{ + connection = await createConnection(connectionOptions); + + await connection.runMigrations({ + transaction: "none" + }); + }catch(e){ + throw new Error("Couldn't connect to db / migrate stuff.") + } + + + + return connection.isConnected; +}; diff --git a/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts b/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts new file mode 100644 index 0000000000..d5e897e923 --- /dev/null +++ b/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts @@ -0,0 +1,22 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class InitialMigration1587669153312 implements MigrationInterface { + name = 'InitialMigration1587669153312' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE credentials_entity (id SERIAL NOT NULL, name character varying(128) NOT NULL, data text NOT NULL, type character varying(32) NOT NULL, nodesAccess json NOT NULL, createdAt TIMESTAMP NOT NULL, updatedAt TIMESTAMP NOT NULL, CONSTRAINT PK_814c3d3c36e8a27fa8edb761b0e PRIMARY KEY (id))`, undefined); + await queryRunner.query(`CREATE INDEX IDX_07fde106c0b471d8cc80a64fc8 ON credentials_entity (type) `, undefined); + await queryRunner.query(`CREATE TABLE execution_entity (id SERIAL NOT NULL, data text NOT NULL, finished boolean NOT NULL, mode character varying NOT NULL, retryOf character varying, retrySuccessId character varying, startedAt TIMESTAMP NOT NULL, stoppedAt TIMESTAMP NOT NULL, workflowData json NOT NULL, workflowId character varying, CONSTRAINT PK_e3e63bbf986767844bbe1166d4e PRIMARY KEY (id))`, undefined); + await queryRunner.query(`CREATE INDEX IDX_c4d999a5e90784e8caccf5589d ON execution_entity (workflowId) `, undefined); + await queryRunner.query(`CREATE TABLE workflow_entity (id SERIAL NOT NULL, name character varying(128) NOT NULL, active boolean NOT NULL, nodes json NOT NULL, connections json NOT NULL, createdAt TIMESTAMP NOT NULL, updatedAt TIMESTAMP NOT NULL, settings json, staticData json, CONSTRAINT PK_eded7d72664448da7745d551207 PRIMARY KEY (id))`, undefined); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE workflow_entity`, undefined); + await queryRunner.query(`DROP INDEX IDX_c4d999a5e90784e8caccf5589d`, undefined); + await queryRunner.query(`DROP TABLE execution_entity`, undefined); + await queryRunner.query(`DROP INDEX IDX_07fde106c0b471d8cc80a64fc8`, undefined); + await queryRunner.query(`DROP TABLE credentials_entity`, undefined); + } + +} diff --git a/packages/cli/src/databases/sqlite/index.ts b/packages/cli/src/databases/sqlite/index.ts index 164d67fd0c..2c7d6e25e9 100644 --- a/packages/cli/src/databases/sqlite/index.ts +++ b/packages/cli/src/databases/sqlite/index.ts @@ -1,3 +1,4 @@ export * from './CredentialsEntity'; export * from './ExecutionEntity'; export * from './WorkflowEntity'; + diff --git a/packages/cli/src/databases/sqlite/migrations/1587628010571-InitialMigration.ts b/packages/cli/src/databases/sqlite/migrations/1587628010571-InitialMigration.ts new file mode 100644 index 0000000000..98dd98a5be --- /dev/null +++ b/packages/cli/src/databases/sqlite/migrations/1587628010571-InitialMigration.ts @@ -0,0 +1,23 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class InitialMigration1587628010571 implements MigrationInterface { + name = 'InitialMigration1587628010571' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE test_table ( + id INTEGER PRIMARY KEY, + name TEXT NOT NULL, + second_name TEXT NOT NULL + )`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE test_table`); + } + + + +/** + * await queryRunner.query(`ALTER TABLE credentials_entity RENAME TO _credentials_entity_old`, undefined); + await queryRunner.query(`CREATE TABLE credentials_entity ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(128) NOT NULL, "data" text NOT NULL, "type" varchar(32) NOT NULL, "nodesAccess" text NOT NULL, "createdAt" datetime NOT NULL, "updatedAt" datetime NOT NULL, "testCol" text)`, undefined); + await queryRunner.query(`INSERT INTO credentials_entity (id, name, data, type, nodesAccess, createdAt, updatedAt) SELECT id, name, data, type, nodesAccess, createdAt, updatedAt FROM _credentials_entity_old`) */} From 032f4075e436f42abe438c5fc1efd9e1bb6af212 Mon Sep 17 00:00:00 2001 From: Rupenieks Date: Tue, 28 Apr 2020 00:52:30 +0200 Subject: [PATCH 4/8] postgresql initial migration --- packages/cli/commands/start.ts | 6 +-- packages/cli/src/Db.ts | 46 +++++++++++++++---- .../1587563465704-InitialMigration.ts | 11 ----- .../1587669153312-InitialMigration.ts | 10 ++-- 4 files changed, 42 insertions(+), 31 deletions(-) delete mode 100644 packages/cli/src/databases/postgresdb/Migrations/1587563465704-InitialMigration.ts diff --git a/packages/cli/commands/start.ts b/packages/cli/commands/start.ts index 00789b9b43..4e2efaacfd 100644 --- a/packages/cli/commands/start.ts +++ b/packages/cli/commands/start.ts @@ -115,11 +115,7 @@ export class Start extends Command { await credentialTypes.init(loadNodesAndCredentials.credentialTypes); // Wait till the database is ready - let dbReady = await startDbInitPromise; - - if(!dbReady){ - throw new Error("DB did not initialize."); - } + await startDbInitPromise; if (flags.tunnel === true) { this.log('\nWaiting for tunnel ...'); diff --git a/packages/cli/src/Db.ts b/packages/cli/src/Db.ts index 29c94508aa..25c289d7ac 100644 --- a/packages/cli/src/Db.ts +++ b/packages/cli/src/Db.ts @@ -28,9 +28,11 @@ export let collections: IDatabaseCollections = { Workflow: null, }; +import InitialMigration1587669153312 from './databases/postgresdb/migrations/1587669153312-InitialMigration' + import * as path from 'path'; -export async function init(synchronize?: boolean): Promise { +export async function init(synchronize?: boolean): Promise { const dbType = await GenericHelpers.getConfigValue('database.type') as DatabaseType; const n8nFolder = UserSettings.getUserN8nFolderPath(); @@ -63,7 +65,7 @@ export async function init(synchronize?: boolean): Promise { port: await GenericHelpers.getConfigValue('database.postgresdb.port') as number, username: await GenericHelpers.getConfigValue('database.postgresdb.user') as string, schema: await GenericHelpers.getConfigValue('database.postgresdb.schema') as string, - migrations: ['./databases/postgresdb/migrations/*.js'] + migrations: [InitialMigration1587669153312] }; break; @@ -105,21 +107,45 @@ export async function init(synchronize?: boolean): Promise { migrationsRun: true }); - for(let i = 0; i < 1000; i++){ - console.log(connectionOptions); - } - try{ connection = await createConnection(connectionOptions); - await connection.runMigrations({ - transaction: "none" + let migrations = await connection.runMigrations({ + transaction: 'none' }); + + console.log(migrations); + }catch(e){ - throw new Error("Couldn't connect to db / migrate stuff.") + console.log(`Error: ${e}`); + return e; } + // TODO: Fix that properly + // @ts-ignore + collections.Credentials = getRepository(entities.CredentialsEntity); + // @ts-ignore + collections.Execution = getRepository(entities.ExecutionEntity); + // @ts-ignore + collections.Workflow = getRepository(entities.WorkflowEntity); + // Make sure that database did already get initialized + try { + // Try a simple query, if it fails it is normally a sign that + // database did not get initialized + await collections.Execution!.findOne({ id: 1 }); + } catch (error) { + // If query errors and the problem is that the database does not exist + // run the init again with "synchronize: true" + if (dbNotExistError !== undefined && error.message.includes(dbNotExistError)) { + // Disconnect before we try to connect again + if (connection.isConnected) { + await connection.close(); + } - return connection.isConnected; + return init(true); + } + } + return collections; + }; diff --git a/packages/cli/src/databases/postgresdb/Migrations/1587563465704-InitialMigration.ts b/packages/cli/src/databases/postgresdb/Migrations/1587563465704-InitialMigration.ts deleted file mode 100644 index bcab733bf6..0000000000 --- a/packages/cli/src/databases/postgresdb/Migrations/1587563465704-InitialMigration.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {MigrationInterface, QueryRunner} from "typeorm"; - -export class InitialMigration1587563465704 implements MigrationInterface { - - public async up(queryRunner: QueryRunner): Promise { - } - - public async down(queryRunner: QueryRunner): Promise { - } - -} diff --git a/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts b/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts index d5e897e923..045eb408d4 100644 --- a/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts +++ b/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts @@ -1,14 +1,14 @@ import {MigrationInterface, QueryRunner} from "typeorm"; -export class InitialMigration1587669153312 implements MigrationInterface { +export default class InitialMigration1587669153312 implements MigrationInterface { name = 'InitialMigration1587669153312' public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE credentials_entity (id SERIAL NOT NULL, name character varying(128) NOT NULL, data text NOT NULL, type character varying(32) NOT NULL, nodesAccess json NOT NULL, createdAt TIMESTAMP NOT NULL, updatedAt TIMESTAMP NOT NULL, CONSTRAINT PK_814c3d3c36e8a27fa8edb761b0e PRIMARY KEY (id))`, undefined); + await queryRunner.query(`CREATE TABLE credentials_entity (id SERIAL NOT NULL, "name" character varying(128) NOT NULL, "data" text NOT NULL, "type" character varying(32) NOT NULL, "nodesAccess" json NOT NULL, "createdAt" TIMESTAMP NOT NULL, "updatedAt" TIMESTAMP NOT NULL, CONSTRAINT PK_814c3d3c36e8a27fa8edb761b0e PRIMARY KEY (id))`, undefined); await queryRunner.query(`CREATE INDEX IDX_07fde106c0b471d8cc80a64fc8 ON credentials_entity (type) `, undefined); - await queryRunner.query(`CREATE TABLE execution_entity (id SERIAL NOT NULL, data text NOT NULL, finished boolean NOT NULL, mode character varying NOT NULL, retryOf character varying, retrySuccessId character varying, startedAt TIMESTAMP NOT NULL, stoppedAt TIMESTAMP NOT NULL, workflowData json NOT NULL, workflowId character varying, CONSTRAINT PK_e3e63bbf986767844bbe1166d4e PRIMARY KEY (id))`, undefined); - await queryRunner.query(`CREATE INDEX IDX_c4d999a5e90784e8caccf5589d ON execution_entity (workflowId) `, undefined); - await queryRunner.query(`CREATE TABLE workflow_entity (id SERIAL NOT NULL, name character varying(128) NOT NULL, active boolean NOT NULL, nodes json NOT NULL, connections json NOT NULL, createdAt TIMESTAMP NOT NULL, updatedAt TIMESTAMP NOT NULL, settings json, staticData json, CONSTRAINT PK_eded7d72664448da7745d551207 PRIMARY KEY (id))`, undefined); + await queryRunner.query(`CREATE TABLE execution_entity (id SERIAL NOT NULL, "data" text NOT NULL, "finished" boolean NOT NULL, "mode" character varying NOT NULL, "retryOf" character varying, "retrySuccessId" character varying, "startedAt" TIMESTAMP NOT NULL, "stoppedAt" TIMESTAMP NOT NULL, "workflowData" json NOT NULL, "workflowId" character varying, CONSTRAINT PK_e3e63bbf986767844bbe1166d4e PRIMARY KEY (id))`, undefined); + await queryRunner.query(`CREATE INDEX IDX_c4d999a5e90784e8caccf5589d ON execution_entity ("workflowId") `, undefined); + await queryRunner.query(`CREATE TABLE workflow_entity (id SERIAL NOT NULL, "name" character varying(128) NOT NULL, "active" boolean NOT NULL, "nodes" json NOT NULL, "connections" json NOT NULL, "createdAt" TIMESTAMP NOT NULL, "updatedAt" TIMESTAMP NOT NULL, "settings" json, "staticData" json, CONSTRAINT PK_eded7d72664448da7745d551207 PRIMARY KEY (id))`, undefined); } public async down(queryRunner: QueryRunner): Promise { From 16bf916df5cff915993632d849353589741e3851 Mon Sep 17 00:00:00 2001 From: Rupenieks Date: Wed, 29 Apr 2020 11:34:12 +0200 Subject: [PATCH 5/8] Migration configs, migration files, removed test queries --- packages/cli/databases/sqlite/database.sqlite | Bin 0 -> 32768 bytes packages/cli/ormconfig.ts | 37 ++++++++- packages/cli/package.json | 2 +- packages/cli/packages/cli/database.sqlite | 0 packages/cli/src/Db.ts | 73 ++++++++---------- .../1587563497207-InitialMigration.ts | 11 --- .../1588086339467-InitialMigration.ts | 20 +++++ .../src/databases/mysqldb/migrations/index.ts | 1 + .../databases/postgresdb/CredentialsEntity.ts | 1 + .../1587669153312-InitialMigration.ts | 8 +- .../databases/postgresdb/migrations/index.ts | 1 + .../1587563481290-InitialMigration.ts | 11 --- .../1587628010571-InitialMigration.ts | 23 ------ .../1588102412422-InitialMigration.ts | 22 ++++++ .../src/databases/sqlite/migrations/index.ts | 1 + 15 files changed, 116 insertions(+), 95 deletions(-) create mode 100644 packages/cli/databases/sqlite/database.sqlite create mode 100644 packages/cli/packages/cli/database.sqlite delete mode 100644 packages/cli/src/databases/mysqldb/Migrations/1587563497207-InitialMigration.ts create mode 100644 packages/cli/src/databases/mysqldb/migrations/1588086339467-InitialMigration.ts create mode 100644 packages/cli/src/databases/mysqldb/migrations/index.ts create mode 100644 packages/cli/src/databases/postgresdb/migrations/index.ts delete mode 100644 packages/cli/src/databases/sqlite/Migrations/1587563481290-InitialMigration.ts delete mode 100644 packages/cli/src/databases/sqlite/migrations/1587628010571-InitialMigration.ts create mode 100644 packages/cli/src/databases/sqlite/migrations/1588102412422-InitialMigration.ts create mode 100644 packages/cli/src/databases/sqlite/migrations/index.ts diff --git a/packages/cli/databases/sqlite/database.sqlite b/packages/cli/databases/sqlite/database.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..85193ea1519804e043af021120849fb2b25533a1 GIT binary patch literal 32768 zcmeI&T~FFj90u?fdC@t>?zlbnW)O9u2wJW-HilovgI5pXFn8jL>j3|BqkZU zL=2PBDz(YcasDuSd`=E>=OlYtF6E27`C+bDCdCqeofZlkL^9PnmB@{1Ygeirlaor^ zTU9k?-0=FPW!0!^dP}CIQ%53<-ZAfP%`#2OTUq9$qD@ss^(>Q!&R3XGr{1>BhP!ua z*`bUXX0>}>e(erZnW62fOzm7py!9#=ism=P)|O%F^e(@9cA=&8OeUkIX(q9wq^P2) znpR1tl?<;_t?6E9*E-b2%@=obXGEIaSR$n&kw#D9CeRBduS;?AU<5+Z%}w!Zpq=jM z@uS&lQbyIh3!shd|IkE_>E;$ z`AqB`wL?kt3vu_^T#Wn@_#YMsKmY;|fB*y_009U<00Izz00f?wz#Gvo1op)1AA8@w z { +export async function init(): Promise { const dbType = await GenericHelpers.getConfigValue('database.type') as DatabaseType; const n8nFolder = UserSettings.getUserN8nFolderPath(); @@ -49,7 +59,6 @@ export async function init(synchronize?: boolean): Promise entityPrefix: await GenericHelpers.getConfigValue('database.tablePrefix') as string, url: await GenericHelpers.getConfigValue('database.mongodb.connectionUrl') as string, useNewUrlParser: true, - migrations: ['./databases/mongodb/migrations/*.js'], }; break; @@ -65,7 +74,8 @@ export async function init(synchronize?: boolean): Promise port: await GenericHelpers.getConfigValue('database.postgresdb.port') as number, username: await GenericHelpers.getConfigValue('database.postgresdb.user') as string, schema: await GenericHelpers.getConfigValue('database.postgresdb.schema') as string, - migrations: [InitialMigration1587669153312] + migrations: [InitialMigration1587669153312], + migrationsRun: true }; break; @@ -81,7 +91,8 @@ export async function init(synchronize?: boolean): Promise password: await GenericHelpers.getConfigValue('database.mysqldb.password') as string, port: await GenericHelpers.getConfigValue('database.mysqldb.port') as number, username: await GenericHelpers.getConfigValue('database.mysqldb.user') as string, - migrations: ['./databases/mysqldb/migrations/*.js'] + migrations: [InitialMigration1588086339467], + migrationsRun: true }; break; @@ -92,7 +103,8 @@ export async function init(synchronize?: boolean): Promise type: 'sqlite', database: path.join(n8nFolder, 'database.sqlite'), entityPrefix: await GenericHelpers.getConfigValue('database.tablePrefix') as string, - migrations: ['./databases/sqlite/migrations/*.js'], + migrations: [InitialMigration1588102412422], + migrationsRun: true }; break; @@ -102,50 +114,29 @@ export async function init(synchronize?: boolean): Promise Object.assign(connectionOptions, { entities: Object.values(entities), - synchronize: false,//synchronize === true || process.env['NODE_ENV'] !== 'production', - logging: true, - migrationsRun: true + synchronize: false, }); - try{ + try { connection = await createConnection(connectionOptions); - let migrations = await connection.runMigrations({ + await connection.runMigrations({ transaction: 'none' }); - console.log(migrations); - - }catch(e){ - console.log(`Error: ${e}`); - return e; - } - - // TODO: Fix that properly - // @ts-ignore - collections.Credentials = getRepository(entities.CredentialsEntity); - // @ts-ignore - collections.Execution = getRepository(entities.ExecutionEntity); - // @ts-ignore - collections.Workflow = getRepository(entities.WorkflowEntity); - - // Make sure that database did already get initialized - try { - // Try a simple query, if it fails it is normally a sign that - // database did not get initialized - await collections.Execution!.findOne({ id: 1 }); - } catch (error) { - // If query errors and the problem is that the database does not exist - // run the init again with "synchronize: true" - if (dbNotExistError !== undefined && error.message.includes(dbNotExistError)) { - // Disconnect before we try to connect again - if (connection.isConnected) { - await connection.close(); - } - - return init(true); + + if(connection.isConnected){ + collections.Credentials = getRepository(entities.CredentialsEntity); + collections.Execution = getRepository(entities.ExecutionEntity); + collections.Workflow = getRepository(entities.WorkflowEntity); + } else { + init(); } + + } catch (e){ + console.log(e); } + return collections; }; diff --git a/packages/cli/src/databases/mysqldb/Migrations/1587563497207-InitialMigration.ts b/packages/cli/src/databases/mysqldb/Migrations/1587563497207-InitialMigration.ts deleted file mode 100644 index 1a083bd65a..0000000000 --- a/packages/cli/src/databases/mysqldb/Migrations/1587563497207-InitialMigration.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {MigrationInterface, QueryRunner} from "typeorm"; - -export class InitialMigration1587563497207 implements MigrationInterface { - - public async up(queryRunner: QueryRunner): Promise { - } - - public async down(queryRunner: QueryRunner): Promise { - } - -} diff --git a/packages/cli/src/databases/mysqldb/migrations/1588086339467-InitialMigration.ts b/packages/cli/src/databases/mysqldb/migrations/1588086339467-InitialMigration.ts new file mode 100644 index 0000000000..8cadd12d6d --- /dev/null +++ b/packages/cli/src/databases/mysqldb/migrations/1588086339467-InitialMigration.ts @@ -0,0 +1,20 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class InitialMigration1588086339467 implements MigrationInterface { + name = 'InitialMigration1588086339467' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query("CREATE TABLE `credentials_entity` (`id` int NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, `data` text NOT NULL, `type` varchar(32) NOT NULL, `nodesAccess` json NOT NULL, `createdAt` datetime NOT NULL, `updatedAt` datetime NOT NULL, INDEX `IDX_07fde106c0b471d8cc80a64fc8` (`type`), PRIMARY KEY (`id`)) ENGINE=InnoDB", undefined); + await queryRunner.query("CREATE TABLE `execution_entity` (`id` int NOT NULL AUTO_INCREMENT, `data` text NOT NULL, `finished` tinyint NOT NULL, `mode` varchar(255) NOT NULL, `retryOf` varchar(255) NULL, `retrySuccessId` varchar(255) NULL, `startedAt` datetime NOT NULL, `stoppedAt` datetime NOT NULL, `workflowData` json NOT NULL, `workflowId` varchar(255) NULL, INDEX `IDX_c4d999a5e90784e8caccf5589d` (`workflowId`), PRIMARY KEY (`id`)) ENGINE=InnoDB", undefined); + await queryRunner.query("CREATE TABLE `workflow_entity` (`id` int NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, `active` tinyint NOT NULL, `nodes` json NOT NULL, `connections` json NOT NULL, `createdAt` datetime NOT NULL, `updatedAt` datetime NOT NULL, `settings` json NULL, `staticData` json NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB", undefined); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query("DROP TABLE `workflow_entity`", undefined); + await queryRunner.query("DROP INDEX `IDX_c4d999a5e90784e8caccf5589d` ON `execution_entity`", undefined); + await queryRunner.query("DROP TABLE `execution_entity`", undefined); + await queryRunner.query("DROP INDEX `IDX_07fde106c0b471d8cc80a64fc8` ON `credentials_entity`", undefined); + await queryRunner.query("DROP TABLE `credentials_entity`", undefined); + } + +} diff --git a/packages/cli/src/databases/mysqldb/migrations/index.ts b/packages/cli/src/databases/mysqldb/migrations/index.ts new file mode 100644 index 0000000000..22aa052ac1 --- /dev/null +++ b/packages/cli/src/databases/mysqldb/migrations/index.ts @@ -0,0 +1 @@ +export * from './1588086339467-InitialMigration'; \ No newline at end of file diff --git a/packages/cli/src/databases/postgresdb/CredentialsEntity.ts b/packages/cli/src/databases/postgresdb/CredentialsEntity.ts index e3ef375254..cddaf7559f 100644 --- a/packages/cli/src/databases/postgresdb/CredentialsEntity.ts +++ b/packages/cli/src/databases/postgresdb/CredentialsEntity.ts @@ -41,4 +41,5 @@ export class CredentialsEntity implements ICredentialsDb { @Column('timestamp') updatedAt: Date; + } diff --git a/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts b/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts index 045eb408d4..520be3fcd0 100644 --- a/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts +++ b/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts @@ -1,14 +1,14 @@ import {MigrationInterface, QueryRunner} from "typeorm"; -export default class InitialMigration1587669153312 implements MigrationInterface { +export class InitialMigration1587669153312 implements MigrationInterface { name = 'InitialMigration1587669153312' public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE credentials_entity (id SERIAL NOT NULL, "name" character varying(128) NOT NULL, "data" text NOT NULL, "type" character varying(32) NOT NULL, "nodesAccess" json NOT NULL, "createdAt" TIMESTAMP NOT NULL, "updatedAt" TIMESTAMP NOT NULL, CONSTRAINT PK_814c3d3c36e8a27fa8edb761b0e PRIMARY KEY (id))`, undefined); + await queryRunner.query(`CREATE TABLE credentials_entity ("id" SERIAL NOT NULL, "name" character varying(128) NOT NULL, "data" text NOT NULL, "type" character varying(32) NOT NULL, "nodesAccess" json NOT NULL, "createdAt" TIMESTAMP NOT NULL, "updatedAt" TIMESTAMP NOT NULL, CONSTRAINT PK_814c3d3c36e8a27fa8edb761b0e PRIMARY KEY ("id"))`, undefined); await queryRunner.query(`CREATE INDEX IDX_07fde106c0b471d8cc80a64fc8 ON credentials_entity (type) `, undefined); - await queryRunner.query(`CREATE TABLE execution_entity (id SERIAL NOT NULL, "data" text NOT NULL, "finished" boolean NOT NULL, "mode" character varying NOT NULL, "retryOf" character varying, "retrySuccessId" character varying, "startedAt" TIMESTAMP NOT NULL, "stoppedAt" TIMESTAMP NOT NULL, "workflowData" json NOT NULL, "workflowId" character varying, CONSTRAINT PK_e3e63bbf986767844bbe1166d4e PRIMARY KEY (id))`, undefined); + await queryRunner.query(`CREATE TABLE execution_entity ("id" SERIAL NOT NULL, "data" text NOT NULL, "finished" boolean NOT NULL, "mode" character varying NOT NULL, "retryOf" character varying, "retrySuccessId" character varying, "startedAt" TIMESTAMP NOT NULL, "stoppedAt" TIMESTAMP NOT NULL, "workflowData" json NOT NULL, "workflowId" character varying, CONSTRAINT PK_e3e63bbf986767844bbe1166d4e PRIMARY KEY ("id"))`, undefined); await queryRunner.query(`CREATE INDEX IDX_c4d999a5e90784e8caccf5589d ON execution_entity ("workflowId") `, undefined); - await queryRunner.query(`CREATE TABLE workflow_entity (id SERIAL NOT NULL, "name" character varying(128) NOT NULL, "active" boolean NOT NULL, "nodes" json NOT NULL, "connections" json NOT NULL, "createdAt" TIMESTAMP NOT NULL, "updatedAt" TIMESTAMP NOT NULL, "settings" json, "staticData" json, CONSTRAINT PK_eded7d72664448da7745d551207 PRIMARY KEY (id))`, undefined); + await queryRunner.query(`CREATE TABLE workflow_entity ("id" SERIAL NOT NULL, "name" character varying(128) NOT NULL, "active" boolean NOT NULL, "nodes" json NOT NULL, "connections" json NOT NULL, "createdAt" TIMESTAMP NOT NULL, "updatedAt" TIMESTAMP NOT NULL, "settings" json, "staticData" json, CONSTRAINT PK_eded7d72664448da7745d551207 PRIMARY KEY ("id"))`, undefined); } public async down(queryRunner: QueryRunner): Promise { diff --git a/packages/cli/src/databases/postgresdb/migrations/index.ts b/packages/cli/src/databases/postgresdb/migrations/index.ts new file mode 100644 index 0000000000..5bb6551492 --- /dev/null +++ b/packages/cli/src/databases/postgresdb/migrations/index.ts @@ -0,0 +1 @@ +export * from './1587669153312-InitialMigration'; diff --git a/packages/cli/src/databases/sqlite/Migrations/1587563481290-InitialMigration.ts b/packages/cli/src/databases/sqlite/Migrations/1587563481290-InitialMigration.ts deleted file mode 100644 index 20d30f068d..0000000000 --- a/packages/cli/src/databases/sqlite/Migrations/1587563481290-InitialMigration.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {MigrationInterface, QueryRunner} from "typeorm"; - -export class InitialMigration1587563481290 implements MigrationInterface { - - public async up(queryRunner: QueryRunner): Promise { - } - - public async down(queryRunner: QueryRunner): Promise { - } - -} diff --git a/packages/cli/src/databases/sqlite/migrations/1587628010571-InitialMigration.ts b/packages/cli/src/databases/sqlite/migrations/1587628010571-InitialMigration.ts deleted file mode 100644 index 98dd98a5be..0000000000 --- a/packages/cli/src/databases/sqlite/migrations/1587628010571-InitialMigration.ts +++ /dev/null @@ -1,23 +0,0 @@ -import {MigrationInterface, QueryRunner} from "typeorm"; - -export class InitialMigration1587628010571 implements MigrationInterface { - name = 'InitialMigration1587628010571' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE test_table ( - id INTEGER PRIMARY KEY, - name TEXT NOT NULL, - second_name TEXT NOT NULL - )`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DROP TABLE test_table`); - } - - - -/** - * await queryRunner.query(`ALTER TABLE credentials_entity RENAME TO _credentials_entity_old`, undefined); - await queryRunner.query(`CREATE TABLE credentials_entity ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(128) NOT NULL, "data" text NOT NULL, "type" varchar(32) NOT NULL, "nodesAccess" text NOT NULL, "createdAt" datetime NOT NULL, "updatedAt" datetime NOT NULL, "testCol" text)`, undefined); - await queryRunner.query(`INSERT INTO credentials_entity (id, name, data, type, nodesAccess, createdAt, updatedAt) SELECT id, name, data, type, nodesAccess, createdAt, updatedAt FROM _credentials_entity_old`) */} diff --git a/packages/cli/src/databases/sqlite/migrations/1588102412422-InitialMigration.ts b/packages/cli/src/databases/sqlite/migrations/1588102412422-InitialMigration.ts new file mode 100644 index 0000000000..ccad7e6dd8 --- /dev/null +++ b/packages/cli/src/databases/sqlite/migrations/1588102412422-InitialMigration.ts @@ -0,0 +1,22 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class InitialMigration1588102412422 implements MigrationInterface { + name = 'InitialMigration1588102412422' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE "credentials_entity" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(128) NOT NULL, "data" text NOT NULL, "type" varchar(32) NOT NULL, "nodesAccess" text NOT NULL, "createdAt" datetime NOT NULL, "updatedAt" datetime NOT NULL)`, undefined); + await queryRunner.query(`CREATE INDEX "IDX_07fde106c0b471d8cc80a64fc8" ON "credentials_entity" ("type") `, undefined); + await queryRunner.query(`CREATE TABLE "execution_entity" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "data" text NOT NULL, "finished" boolean NOT NULL, "mode" varchar NOT NULL, "retryOf" varchar, "retrySuccessId" varchar, "startedAt" datetime NOT NULL, "stoppedAt" datetime NOT NULL, "workflowData" text NOT NULL, "workflowId" varchar)`, undefined); + await queryRunner.query(`CREATE INDEX "IDX_c4d999a5e90784e8caccf5589d" ON "execution_entity" ("workflowId") `, undefined); + await queryRunner.query(`CREATE TABLE "workflow_entity" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(128) NOT NULL, "active" boolean NOT NULL, "nodes" text NOT NULL, "connections" text NOT NULL, "createdAt" datetime NOT NULL, "updatedAt" datetime NOT NULL, "settings" text, "staticData" text)`, undefined); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE "workflow_entity"`, undefined); + await queryRunner.query(`DROP INDEX "IDX_c4d999a5e90784e8caccf5589d"`, undefined); + await queryRunner.query(`DROP TABLE "execution_entity"`, undefined); + await queryRunner.query(`DROP INDEX "IDX_07fde106c0b471d8cc80a64fc8"`, undefined); + await queryRunner.query(`DROP TABLE "credentials_entity"`, undefined); + } + +} diff --git a/packages/cli/src/databases/sqlite/migrations/index.ts b/packages/cli/src/databases/sqlite/migrations/index.ts new file mode 100644 index 0000000000..8d9a0a0b16 --- /dev/null +++ b/packages/cli/src/databases/sqlite/migrations/index.ts @@ -0,0 +1 @@ +export * from './1588102412422-InitialMigration'; \ No newline at end of file From 3acd779282ba6f0ae6f97895e554695dacc1917f Mon Sep 17 00:00:00 2001 From: Rupenieks Date: Wed, 29 Apr 2020 13:57:21 +0200 Subject: [PATCH 6/8] Fixed Queries, --- packages/cli/database.sqlite | Bin 0 -> 32768 bytes packages/cli/src/Db.ts | 7 +++--- .../1588086339467-InitialMigration.ts | 20 ------------------ .../1588157391238-InitialMigration.ts | 20 ++++++++++++++++++ .../src/databases/mysqldb/migrations/index.ts | 2 +- .../1587669153312-InitialMigration.ts | 10 ++++----- .../1588102412422-InitialMigration.ts | 10 ++++----- 7 files changed, 35 insertions(+), 34 deletions(-) create mode 100644 packages/cli/database.sqlite delete mode 100644 packages/cli/src/databases/mysqldb/migrations/1588086339467-InitialMigration.ts create mode 100644 packages/cli/src/databases/mysqldb/migrations/1588157391238-InitialMigration.ts diff --git a/packages/cli/database.sqlite b/packages/cli/database.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..491e55bbdc2f7df002eadc648d8cc89f7a73f200 GIT binary patch literal 32768 zcmeI*T~FIq7zc2h04Z%D>!gXxnNv+8BB8buAPE;+Iw%Tn=_o~IRaP1Mgj!AP)IJm# z%0)W1k5uh?7yAgCwtb3yfJu97V)90~;9^qI-%6C&&pEcw@3Ae#@v)zMyJ-uqR9&xb z2qhzZBFVD!wW3IpG*0h3^p1vLd^8%NPr2*+u&?9N{8xWYQZzpCuatP1n3(*1a_!#V z_tt3?0|X!d0SG_<0uX?}|1I!-JszK)o0HEsgmF;g$FBFLT62$IaYxwVv~TpzH#@7v z-Bo3`_;_j%#tBDT1Gf?#ZU>IGk#^&Q(E= z8-iO!!4!+W2)oX^>mD_NsYAm)7s7T9+w-M$_k|&BbHxzG#d;)LQ{(aJQd(|hY{%j! zrIi=2%&e8q=ZyuPSC?{Go-+;8tS&6%@)YOhQLv(I>v$Wtw7s(WLSffeW=eTmVg0iR zG7u%DWU-|3-X4ojr_=IJV_|mt%lD6u_vW`he4_*tX`82;x@tSN|C-a*az$$El-kQ} zqPv#Ig?C!6UdAW~;iP9rrpbMunjCFO7uoTy%cgJ}jp50T7(3bRUXdu;wZvrW{wO71 zlUs9_$yb-E7T458Q$5HoX;#iObE>hJt(rO0<5sYX88yG1{;|RI53hca{=u0984{-r z9;9B4#iun*KED^Hez5G|l+oVw4;Hx525|ize)Z-Nwjs*pY)0=nD1>`{G0gZC`~S^% z@#NEy@!(LnAA-M2X zhYUJ4b-s=C%!zdZH^L4MX>?esH)zMQ59vtUz18+);xdp7ew)jQKO}l#fB*y_009U< z00Izz00bZa0SG|g;}ZCCWKCT|NkpeLb=^yXdMI~009U<00Izz00bZa0SG|gI)PS2zAL3$ zlMh=n%gct}J3QB)_}1Fqn-|)gwsuf_T-HzaynJ!1?EJ8}_-J8IJSsm@_m__AC!X(m zne}XyuFyZS%Nxh9w=(+9iBS!@!idvi!+v?jg02m_LH~^cb8=2P?CFp`Fnm5Am18MJ zT_%D8x~i*bHJjG+yP8(W=mjl5uV*sfv1X+cQaYiyyn(i>hRt$JbG51;GWM4XU){b<3J1S znJ_#-UERay01otprw80!M)#;HJy4Gov=nQ&KHcU%7 { password: await GenericHelpers.getConfigValue('database.mysqldb.password') as string, port: await GenericHelpers.getConfigValue('database.mysqldb.port') as number, username: await GenericHelpers.getConfigValue('database.mysqldb.user') as string, - migrations: [InitialMigration1588086339467], + migrations: [InitialMigration1588157391238], migrationsRun: true }; break; @@ -101,7 +101,7 @@ export async function init(): Promise { entities = SQLite; connectionOptions = { type: 'sqlite', - database: path.join(n8nFolder, 'database.sqlite'), + database: path.join(n8nFolder, 'database.sqlite'), entityPrefix: await GenericHelpers.getConfigValue('database.tablePrefix') as string, migrations: [InitialMigration1588102412422], migrationsRun: true @@ -115,6 +115,7 @@ export async function init(): Promise { Object.assign(connectionOptions, { entities: Object.values(entities), synchronize: false, + logging: true }); try { diff --git a/packages/cli/src/databases/mysqldb/migrations/1588086339467-InitialMigration.ts b/packages/cli/src/databases/mysqldb/migrations/1588086339467-InitialMigration.ts deleted file mode 100644 index 8cadd12d6d..0000000000 --- a/packages/cli/src/databases/mysqldb/migrations/1588086339467-InitialMigration.ts +++ /dev/null @@ -1,20 +0,0 @@ -import {MigrationInterface, QueryRunner} from "typeorm"; - -export class InitialMigration1588086339467 implements MigrationInterface { - name = 'InitialMigration1588086339467' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query("CREATE TABLE `credentials_entity` (`id` int NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, `data` text NOT NULL, `type` varchar(32) NOT NULL, `nodesAccess` json NOT NULL, `createdAt` datetime NOT NULL, `updatedAt` datetime NOT NULL, INDEX `IDX_07fde106c0b471d8cc80a64fc8` (`type`), PRIMARY KEY (`id`)) ENGINE=InnoDB", undefined); - await queryRunner.query("CREATE TABLE `execution_entity` (`id` int NOT NULL AUTO_INCREMENT, `data` text NOT NULL, `finished` tinyint NOT NULL, `mode` varchar(255) NOT NULL, `retryOf` varchar(255) NULL, `retrySuccessId` varchar(255) NULL, `startedAt` datetime NOT NULL, `stoppedAt` datetime NOT NULL, `workflowData` json NOT NULL, `workflowId` varchar(255) NULL, INDEX `IDX_c4d999a5e90784e8caccf5589d` (`workflowId`), PRIMARY KEY (`id`)) ENGINE=InnoDB", undefined); - await queryRunner.query("CREATE TABLE `workflow_entity` (`id` int NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, `active` tinyint NOT NULL, `nodes` json NOT NULL, `connections` json NOT NULL, `createdAt` datetime NOT NULL, `updatedAt` datetime NOT NULL, `settings` json NULL, `staticData` json NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB", undefined); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query("DROP TABLE `workflow_entity`", undefined); - await queryRunner.query("DROP INDEX `IDX_c4d999a5e90784e8caccf5589d` ON `execution_entity`", undefined); - await queryRunner.query("DROP TABLE `execution_entity`", undefined); - await queryRunner.query("DROP INDEX `IDX_07fde106c0b471d8cc80a64fc8` ON `credentials_entity`", undefined); - await queryRunner.query("DROP TABLE `credentials_entity`", undefined); - } - -} diff --git a/packages/cli/src/databases/mysqldb/migrations/1588157391238-InitialMigration.ts b/packages/cli/src/databases/mysqldb/migrations/1588157391238-InitialMigration.ts new file mode 100644 index 0000000000..f6aba32791 --- /dev/null +++ b/packages/cli/src/databases/mysqldb/migrations/1588157391238-InitialMigration.ts @@ -0,0 +1,20 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class InitialMigration1588157391238 implements MigrationInterface { + name = 'InitialMigration1588157391238' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query("CREATE TABLE IF NOT EXISTS `credentials_entity` (`id` int NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, `data` text NOT NULL, `type` varchar(32) NOT NULL, `nodesAccess` json NOT NULL, `createdAt` datetime NOT NULL, `updatedAt` datetime NOT NULL, INDEX `IDX_07fde106c0b471d8cc80a64fc8` (`type`), PRIMARY KEY (`id`)) ENGINE=InnoDB", undefined); + await queryRunner.query("CREATE TABLE IF NOT EXISTS `execution_entity` (`id` int NOT NULL AUTO_INCREMENT, `data` text NOT NULL, `finished` tinyint NOT NULL, `mode` varchar(255) NOT NULL, `retryOf` varchar(255) NULL, `retrySuccessId` varchar(255) NULL, `startedAt` datetime NOT NULL, `stoppedAt` datetime NOT NULL, `workflowData` json NOT NULL, `workflowId` varchar(255) NULL, INDEX `IDX_c4d999a5e90784e8caccf5589d` (`workflowId`), PRIMARY KEY (`id`)) ENGINE=InnoDB", undefined); + await queryRunner.query("CREATE TABLE IF NOT EXISTS`workflow_entity` (`id` int NOT NULL AUTO_INCREMENT, `name` varchar(128) NOT NULL, `active` tinyint NOT NULL, `nodes` json NOT NULL, `connections` json NOT NULL, `createdAt` datetime NOT NULL, `updatedAt` datetime NOT NULL, `settings` json NULL, `staticData` json NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB", undefined); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query("DROP TABLE `workflow_entity`", undefined); + await queryRunner.query("DROP INDEX `IDX_c4d999a5e90784e8caccf5589d` ON `execution_entity`", undefined); + await queryRunner.query("DROP TABLE `execution_entity`", undefined); + await queryRunner.query("DROP INDEX `IDX_07fde106c0b471d8cc80a64fc8` ON `credentials_entity`", undefined); + await queryRunner.query("DROP TABLE `credentials_entity`", undefined); + } + +} diff --git a/packages/cli/src/databases/mysqldb/migrations/index.ts b/packages/cli/src/databases/mysqldb/migrations/index.ts index 22aa052ac1..ac2dcab467 100644 --- a/packages/cli/src/databases/mysqldb/migrations/index.ts +++ b/packages/cli/src/databases/mysqldb/migrations/index.ts @@ -1 +1 @@ -export * from './1588086339467-InitialMigration'; \ No newline at end of file +export * from './1588157391238-InitialMigration'; \ No newline at end of file diff --git a/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts b/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts index 520be3fcd0..b26470c797 100644 --- a/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts +++ b/packages/cli/src/databases/postgresdb/migrations/1587669153312-InitialMigration.ts @@ -4,11 +4,11 @@ export class InitialMigration1587669153312 implements MigrationInterface { name = 'InitialMigration1587669153312' public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE credentials_entity ("id" SERIAL NOT NULL, "name" character varying(128) NOT NULL, "data" text NOT NULL, "type" character varying(32) NOT NULL, "nodesAccess" json NOT NULL, "createdAt" TIMESTAMP NOT NULL, "updatedAt" TIMESTAMP NOT NULL, CONSTRAINT PK_814c3d3c36e8a27fa8edb761b0e PRIMARY KEY ("id"))`, undefined); - await queryRunner.query(`CREATE INDEX IDX_07fde106c0b471d8cc80a64fc8 ON credentials_entity (type) `, undefined); - await queryRunner.query(`CREATE TABLE execution_entity ("id" SERIAL NOT NULL, "data" text NOT NULL, "finished" boolean NOT NULL, "mode" character varying NOT NULL, "retryOf" character varying, "retrySuccessId" character varying, "startedAt" TIMESTAMP NOT NULL, "stoppedAt" TIMESTAMP NOT NULL, "workflowData" json NOT NULL, "workflowId" character varying, CONSTRAINT PK_e3e63bbf986767844bbe1166d4e PRIMARY KEY ("id"))`, undefined); - await queryRunner.query(`CREATE INDEX IDX_c4d999a5e90784e8caccf5589d ON execution_entity ("workflowId") `, undefined); - await queryRunner.query(`CREATE TABLE workflow_entity ("id" SERIAL NOT NULL, "name" character varying(128) NOT NULL, "active" boolean NOT NULL, "nodes" json NOT NULL, "connections" json NOT NULL, "createdAt" TIMESTAMP NOT NULL, "updatedAt" TIMESTAMP NOT NULL, "settings" json, "staticData" json, CONSTRAINT PK_eded7d72664448da7745d551207 PRIMARY KEY ("id"))`, undefined); + await queryRunner.query(`CREATE TABLE IF NOT EXISTS credentials_entity ("id" SERIAL NOT NULL, "name" character varying(128) NOT NULL, "data" text NOT NULL, "type" character varying(32) NOT NULL, "nodesAccess" json NOT NULL, "createdAt" TIMESTAMP NOT NULL, "updatedAt" TIMESTAMP NOT NULL, CONSTRAINT PK_814c3d3c36e8a27fa8edb761b0e PRIMARY KEY ("id"))`, undefined); + await queryRunner.query(`CREATE INDEX IF NOT EXISTS IDX_07fde106c0b471d8cc80a64fc8 ON credentials_entity (type) `, undefined); + await queryRunner.query(`CREATE TABLE IF NOT EXISTS execution_entity ("id" SERIAL NOT NULL, "data" text NOT NULL, "finished" boolean NOT NULL, "mode" character varying NOT NULL, "retryOf" character varying, "retrySuccessId" character varying, "startedAt" TIMESTAMP NOT NULL, "stoppedAt" TIMESTAMP NOT NULL, "workflowData" json NOT NULL, "workflowId" character varying, CONSTRAINT PK_e3e63bbf986767844bbe1166d4e PRIMARY KEY ("id"))`, undefined); + await queryRunner.query(`CREATE INDEX IF NOT EXISTS IDX_c4d999a5e90784e8caccf5589d ON execution_entity ("workflowId") `, undefined); + await queryRunner.query(`CREATE TABLE IF NOT EXISTS workflow_entity ("id" SERIAL NOT NULL, "name" character varying(128) NOT NULL, "active" boolean NOT NULL, "nodes" json NOT NULL, "connections" json NOT NULL, "createdAt" TIMESTAMP NOT NULL, "updatedAt" TIMESTAMP NOT NULL, "settings" json, "staticData" json, CONSTRAINT PK_eded7d72664448da7745d551207 PRIMARY KEY ("id"))`, undefined); } public async down(queryRunner: QueryRunner): Promise { diff --git a/packages/cli/src/databases/sqlite/migrations/1588102412422-InitialMigration.ts b/packages/cli/src/databases/sqlite/migrations/1588102412422-InitialMigration.ts index ccad7e6dd8..a68c3f5744 100644 --- a/packages/cli/src/databases/sqlite/migrations/1588102412422-InitialMigration.ts +++ b/packages/cli/src/databases/sqlite/migrations/1588102412422-InitialMigration.ts @@ -4,11 +4,11 @@ export class InitialMigration1588102412422 implements MigrationInterface { name = 'InitialMigration1588102412422' public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "credentials_entity" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(128) NOT NULL, "data" text NOT NULL, "type" varchar(32) NOT NULL, "nodesAccess" text NOT NULL, "createdAt" datetime NOT NULL, "updatedAt" datetime NOT NULL)`, undefined); - await queryRunner.query(`CREATE INDEX "IDX_07fde106c0b471d8cc80a64fc8" ON "credentials_entity" ("type") `, undefined); - await queryRunner.query(`CREATE TABLE "execution_entity" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "data" text NOT NULL, "finished" boolean NOT NULL, "mode" varchar NOT NULL, "retryOf" varchar, "retrySuccessId" varchar, "startedAt" datetime NOT NULL, "stoppedAt" datetime NOT NULL, "workflowData" text NOT NULL, "workflowId" varchar)`, undefined); - await queryRunner.query(`CREATE INDEX "IDX_c4d999a5e90784e8caccf5589d" ON "execution_entity" ("workflowId") `, undefined); - await queryRunner.query(`CREATE TABLE "workflow_entity" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(128) NOT NULL, "active" boolean NOT NULL, "nodes" text NOT NULL, "connections" text NOT NULL, "createdAt" datetime NOT NULL, "updatedAt" datetime NOT NULL, "settings" text, "staticData" text)`, undefined); + await queryRunner.query(`CREATE TABLE IF NOT EXISTS "credentials_entity" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(128) NOT NULL, "data" text NOT NULL, "type" varchar(32) NOT NULL, "nodesAccess" text NOT NULL, "createdAt" datetime NOT NULL, "updatedAt" datetime NOT NULL)`, undefined); + await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_07fde106c0b471d8cc80a64fc8" ON "credentials_entity" ("type") `, undefined); + await queryRunner.query(`CREATE TABLE IF NOT EXISTS "execution_entity" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "data" text NOT NULL, "finished" boolean NOT NULL, "mode" varchar NOT NULL, "retryOf" varchar, "retrySuccessId" varchar, "startedAt" datetime NOT NULL, "stoppedAt" datetime NOT NULL, "workflowData" text NOT NULL, "workflowId" varchar)`, undefined); + await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_c4d999a5e90784e8caccf5589d" ON "execution_entity" ("workflowId") `, undefined); + await queryRunner.query(`CREATE TABLE IF NOT EXISTS "workflow_entity" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(128) NOT NULL, "active" boolean NOT NULL, "nodes" text NOT NULL, "connections" text NOT NULL, "createdAt" datetime NOT NULL, "updatedAt" datetime NOT NULL, "settings" text, "staticData" text)`, undefined); } public async down(queryRunner: QueryRunner): Promise { From 48a1e0c495c0be21fc1938dafa8359de27498a9b Mon Sep 17 00:00:00 2001 From: Rupenieks Date: Wed, 29 Apr 2020 16:13:46 +0200 Subject: [PATCH 7/8] ormconfig to migrations folder --- packages/cli/database.sqlite | Bin 32768 -> 0 bytes packages/cli/{ => migrations}/ormconfig.ts | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 packages/cli/database.sqlite rename packages/cli/{ => migrations}/ormconfig.ts (100%) diff --git a/packages/cli/database.sqlite b/packages/cli/database.sqlite deleted file mode 100644 index 491e55bbdc2f7df002eadc648d8cc89f7a73f200..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmeI*T~FIq7zc2h04Z%D>!gXxnNv+8BB8buAPE;+Iw%Tn=_o~IRaP1Mgj!AP)IJm# z%0)W1k5uh?7yAgCwtb3yfJu97V)90~;9^qI-%6C&&pEcw@3Ae#@v)zMyJ-uqR9&xb z2qhzZBFVD!wW3IpG*0h3^p1vLd^8%NPr2*+u&?9N{8xWYQZzpCuatP1n3(*1a_!#V z_tt3?0|X!d0SG_<0uX?}|1I!-JszK)o0HEsgmF;g$FBFLT62$IaYxwVv~TpzH#@7v z-Bo3`_;_j%#tBDT1Gf?#ZU>IGk#^&Q(E= z8-iO!!4!+W2)oX^>mD_NsYAm)7s7T9+w-M$_k|&BbHxzG#d;)LQ{(aJQd(|hY{%j! zrIi=2%&e8q=ZyuPSC?{Go-+;8tS&6%@)YOhQLv(I>v$Wtw7s(WLSffeW=eTmVg0iR zG7u%DWU-|3-X4ojr_=IJV_|mt%lD6u_vW`he4_*tX`82;x@tSN|C-a*az$$El-kQ} zqPv#Ig?C!6UdAW~;iP9rrpbMunjCFO7uoTy%cgJ}jp50T7(3bRUXdu;wZvrW{wO71 zlUs9_$yb-E7T458Q$5HoX;#iObE>hJt(rO0<5sYX88yG1{;|RI53hca{=u0984{-r z9;9B4#iun*KED^Hez5G|l+oVw4;Hx525|ize)Z-Nwjs*pY)0=nD1>`{G0gZC`~S^% z@#NEy@!(LnAA-M2X zhYUJ4b-s=C%!zdZH^L4MX>?esH)zMQ59vtUz18+);xdp7ew)jQKO}l#fB*y_009U< z00Izz00bZa0SG|g;}ZCCWKCT|NkpeLb=^yXdMI~009U<00Izz00bZa0SG|gI)PS2zAL3$ zlMh=n%gct}J3QB)_}1Fqn-|)gwsuf_T-HzaynJ!1?EJ8}_-J8IJSsm@_m__AC!X(m zne}XyuFyZS%Nxh9w=(+9iBS!@!idvi!+v?jg02m_LH~^cb8=2P?CFp`Fnm5Am18MJ zT_%D8x~i*bHJjG+yP8(W=mjl5uV*sfv1X+cQaYiyyn(i>hRt$JbG51;GWM4XU){b<3J1S znJ_#-UERay01otprw80!M)#;HJy4Gov=nQ&KHcU%7 Date: Mon, 4 May 2020 11:18:28 +0200 Subject: [PATCH 8/8] Ormconfig mariadb addition, ts-node to dev dependency --- packages/cli/migrations/ormconfig.ts | 6 +++--- packages/cli/package.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/cli/migrations/ormconfig.ts b/packages/cli/migrations/ormconfig.ts index ce88a16eae..2a0cda0d9c 100644 --- a/packages/cli/migrations/ormconfig.ts +++ b/packages/cli/migrations/ormconfig.ts @@ -1,4 +1,4 @@ -import {MongoDb, SQLite, MySQLDb, PostgresDb} from './src/databases/index'; +import {MongoDb, SQLite, MySQLDb, PostgresDb} from '../src/databases/index'; module.exports = [ { @@ -84,8 +84,8 @@ module.exports = [ } }, { - "name": "mysql", - "type": "mysql", + "name": "mariadb", + "type": "mariadb", "database": "n8n", "username": "root", "password": "password", diff --git a/packages/cli/package.json b/packages/cli/package.json index 31e47faed0..2cb67af8e0 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -72,7 +72,8 @@ "run-script-os": "^1.0.7", "ts-jest": "^24.0.2", "tslint": "^5.17.0", - "typescript": "~3.7.4" + "typescript": "~3.7.4", + "ts-node": "^8.9.1" }, "dependencies": { "@oclif/command": "^1.5.18", @@ -105,7 +106,6 @@ "request-promise-native": "^1.0.7", "sqlite3": "^4.2.0", "sse-channel": "^3.1.1", - "ts-node": "^8.9.1", "typeorm": "^0.2.24" }, "jest": {