Add MariaDB support

This commit is contained in:
Jan Oberhauser 2020-04-14 19:54:11 +02:00
parent 7ab616f6bc
commit 303062623b
4 changed files with 7 additions and 6 deletions

View file

@ -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)

View file

@ -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'
},

View file

@ -63,11 +63,12 @@ export async function init(synchronize?: boolean): Promise<IDatabaseCollections>
};
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,

View file

@ -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 {