mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 21:07:28 -08:00
🚧 add mySQL migration
This commit is contained in:
parent
575d9fb758
commit
3419d4b69f
|
@ -110,7 +110,7 @@ By default n8n uses SQLite to save credentials, past executions and workflows.
|
|||
n8n however also supports MongoDB and PostgresDB. To use them simply a few
|
||||
environment variables have to be set.
|
||||
|
||||
It is important to still persist the data in the `/root/.n8` folder. The reason
|
||||
It is important to still persist the data in the `/root/.n8n` folder. The reason
|
||||
is that it contains n8n user data. That is the name of the webhook
|
||||
(in case) the n8n tunnel gets used and even more important the encryption key
|
||||
for the credentials. If none gets found n8n creates automatically one on
|
||||
|
|
|
@ -33,19 +33,8 @@ export let collections: IDatabaseCollections = {
|
|||
};
|
||||
|
||||
import postgresMigrations from './databases/postgresdb/migrations';
|
||||
|
||||
import {
|
||||
CreateIndexStoppedAt1594910478695,
|
||||
InitialMigration1587563438936,
|
||||
WebhookModel1592679094242,
|
||||
} from './databases/mongodb/migrations';
|
||||
|
||||
import {
|
||||
CreateIndexStoppedAt1594902918301,
|
||||
InitialMigration1588157391238,
|
||||
WebhookModel1592447867632,
|
||||
} from './databases/mysqldb/migrations';
|
||||
|
||||
import mongodbMigrations from './databases/mongodb/migrations';
|
||||
import mysqlMigrations from './databases/mysqldb/migrations';
|
||||
import sqliteMigrations from './databases/sqlite/migrations';
|
||||
|
||||
import * as path from 'path';
|
||||
|
@ -67,11 +56,7 @@ export async function init(): Promise<IDatabaseCollections> {
|
|||
entityPrefix,
|
||||
url: await GenericHelpers.getConfigValue('database.mongodb.connectionUrl') as string,
|
||||
useNewUrlParser: true,
|
||||
migrations: [
|
||||
InitialMigration1587563438936,
|
||||
WebhookModel1592679094242,
|
||||
CreateIndexStoppedAt1594910478695,
|
||||
],
|
||||
migrations: mongodbMigrations,
|
||||
migrationsRun: true,
|
||||
migrationsTableName: `${entityPrefix}migrations`,
|
||||
};
|
||||
|
@ -123,11 +108,7 @@ export async function init(): Promise<IDatabaseCollections> {
|
|||
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: [
|
||||
InitialMigration1588157391238,
|
||||
WebhookModel1592447867632,
|
||||
CreateIndexStoppedAt1594902918301,
|
||||
],
|
||||
migrations: mysqlMigrations,
|
||||
migrationsRun: true,
|
||||
migrationsTableName: `${entityPrefix}migrations`,
|
||||
};
|
||||
|
|
|
@ -2,6 +2,7 @@ import {
|
|||
Column,
|
||||
Entity,
|
||||
PrimaryColumn,
|
||||
Index,
|
||||
} from 'typeorm';
|
||||
|
||||
import {
|
||||
|
@ -9,6 +10,7 @@ import {
|
|||
} from '../../Interfaces';
|
||||
|
||||
@Entity()
|
||||
@Index(["webhookId", "method"], { unique: true })
|
||||
export class WebhookEntity implements IWebhookDb {
|
||||
|
||||
@Column()
|
||||
|
@ -22,4 +24,7 @@ export class WebhookEntity implements IWebhookDb {
|
|||
|
||||
@Column()
|
||||
node: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
webhookId: string;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import { MigrationInterface, QueryRunner } from 'typeorm';
|
|||
|
||||
import * as config from '../../../../config';
|
||||
|
||||
export class InitialMigration1588157391238 implements MigrationInterface {
|
||||
export default class InitialMigration1588157391238 implements MigrationInterface {
|
||||
name = 'InitialMigration1588157391238';
|
||||
|
||||
async up(queryRunner: QueryRunner): Promise<void> {
|
||||
|
|
|
@ -5,7 +5,7 @@ import {
|
|||
|
||||
import * as config from '../../../../config';
|
||||
|
||||
export class WebhookModel1592447867632 implements MigrationInterface {
|
||||
export default class WebhookModel1592447867632 implements MigrationInterface {
|
||||
name = 'WebhookModel1592447867632';
|
||||
|
||||
async up(queryRunner: QueryRunner): Promise<void> {
|
||||
|
|
|
@ -2,7 +2,7 @@ import { MigrationInterface, QueryRunner } from "typeorm";
|
|||
|
||||
import * as config from '../../../../config';
|
||||
|
||||
export class CreateIndexStoppedAt1594902918301 implements MigrationInterface {
|
||||
export default class CreateIndexStoppedAt1594902918301 implements MigrationInterface {
|
||||
name = 'CreateIndexStoppedAt1594902918301';
|
||||
|
||||
async up(queryRunner: QueryRunner): Promise<void> {
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
import * as config from '../../../../config';
|
||||
|
||||
export default class AddWebhookId1610640521099 implements MigrationInterface {
|
||||
name = 'AddWebhookId1610640521099';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
const tablePrefix = config.get('database.tablePrefix');
|
||||
|
||||
await queryRunner.query('ALTER TABLE `' + tablePrefix + 'webhook_entity` ADD `webhookId` varchar(255) NULL');
|
||||
await queryRunner.query('CREATE UNIQUE INDEX `IDX_' + tablePrefix + 'e1dddabccea3081178199d6004` ON `' + tablePrefix + 'webhook_entity` (`webhookId`, `method`)');
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
const tablePrefix = config.get('database.tablePrefix');
|
||||
|
||||
await queryRunner.query(
|
||||
'DROP INDEX `IDX_' + tablePrefix + 'e1dddabccea3081178199d6004` ON `' + tablePrefix + 'webhook_entity`',
|
||||
);
|
||||
await queryRunner.query('ALTER TABLE `' + tablePrefix + 'webhook_entity` DROP COLUMN `webhookId`');
|
||||
}
|
||||
}
|
|
@ -1,3 +1,11 @@
|
|||
export * from './1588157391238-InitialMigration';
|
||||
export * from './1592447867632-WebhookModel';
|
||||
export * from './1594902918301-CreateIndexStoppedAt';
|
||||
import InitialMigration1588157391238 from './1588157391238-InitialMigration';
|
||||
import WebhookModel1592447867632 from './1592447867632-WebhookModel';
|
||||
import CreateIndexStoppedAt1594902918301 from './1594902918301-CreateIndexStoppedAt';
|
||||
import AddWebhookId1610640521099 from './1610640521099-AddWebhookId'
|
||||
|
||||
export default [
|
||||
InitialMigration1588157391238,
|
||||
WebhookModel1592447867632,
|
||||
CreateIndexStoppedAt1594902918301,
|
||||
AddWebhookId1610640521099,
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue