From 303062623b3ab133eafab1d4037d6d38e071e980 Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Tue, 14 Apr 2020 19:54:11 +0200 Subject: [PATCH] :sparkles: Add MariaDB support --- docs/database.md | 6 +++--- packages/cli/config/index.ts | 2 +- packages/cli/src/Db.ts | 3 ++- packages/cli/src/Interfaces.ts | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/database.md b/docs/database.md index 8fa4325394..8daf5970ce 100644 --- a/docs/database.md +++ b/docs/database.md @@ -60,12 +60,12 @@ export DB_POSTGRESDB_SCHEMA=n8n n8n start ``` -## MySQL +## MySQL / MariaDB -The compatibility with MySQL was tested, even so, it is advisable to observe the operation of the application with this DB, as it is a new option, recently added. If you spot any problems, feel free to submit a PR. +The compatibility with MySQL/MariaDB was tested, even so, it is advisable to observe the operation of the application with this DB, as it is a new option, recently added. If you spot any problems, feel free to submit a PR. To use MySQL as database you can provide the following environment variables: - - `DB_TYPE=mysqldb` + - `DB_TYPE=mysqldb` or `DB_TYPE=mariadb` - `DB_MYSQLDB_DATABASE` (default: 'n8n') - `DB_MYSQLDB_HOST` (default: 'localhost') - `DB_MYSQLDB_PORT` (default: 3306) diff --git a/packages/cli/config/index.ts b/packages/cli/config/index.ts index a3b800279e..69b3154064 100644 --- a/packages/cli/config/index.ts +++ b/packages/cli/config/index.ts @@ -8,7 +8,7 @@ const config = convict({ database: { type: { doc: 'Type of database to use', - format: ['sqlite', 'mongodb', 'mysqldb', 'postgresdb'], + format: ['sqlite', 'mariadb', 'mongodb', 'mysqldb', 'postgresdb'], default: 'sqlite', env: 'DB_TYPE' }, diff --git a/packages/cli/src/Db.ts b/packages/cli/src/Db.ts index a97cbaa837..ed24baabd2 100644 --- a/packages/cli/src/Db.ts +++ b/packages/cli/src/Db.ts @@ -63,11 +63,12 @@ export async function init(synchronize?: boolean): Promise }; break; + case 'mariadb': case 'mysqldb': dbNotExistError = 'does not exist'; entities = MySQLDb; connectionOptions = { - type: 'mysql', + type: dbType === 'mysqldb' ? 'mysql' : 'mariadb', database: await GenericHelpers.getConfigValue('database.mysqldb.database') as string, entityPrefix: await GenericHelpers.getConfigValue('database.tablePrefix') as string, host: await GenericHelpers.getConfigValue('database.mysqldb.host') as string, diff --git a/packages/cli/src/Interfaces.ts b/packages/cli/src/Interfaces.ts index 33d7b02e7f..225e02885f 100644 --- a/packages/cli/src/Interfaces.ts +++ b/packages/cli/src/Interfaces.ts @@ -87,7 +87,7 @@ export interface ICredentialsDecryptedResponse extends ICredentialsDecryptedDb { id: string; } -export type DatabaseType = 'mongodb' | 'postgresdb' | 'mysqldb' | 'sqlite'; +export type DatabaseType = 'mariadb' | 'mongodb' | 'postgresdb' | 'mysqldb' | 'sqlite'; export type SaveExecutionDataType = 'all' | 'none'; export interface IExecutionBase {