refactor: consolidate database configs (#4522)

* consolidate db configs

* allow using custom file-name for the sqlite db

* remove the unused `logging` config. it's overwritten in Db.ts
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2022-11-04 14:23:58 +01:00
committed by GitHub
parent 40e413d958
commit eb3fffd203
4 changed files with 112 additions and 106 deletions

View File

@@ -1,70 +1,13 @@
import path from 'path';
import { UserSettings } from 'n8n-core';
import { entities } from './entities';
const MIGRATIONS_DIR = path.resolve('src', 'databases', 'migrations');
const ENTITIES_DIR = path.resolve('src', 'databases', 'entities');
import {
getMariaDBConnectionOptions,
getMysqlConnectionOptions,
getPostgresConnectionOptions,
getSqliteConnectionOptions,
} from './config';
export default [
{
name: 'sqlite',
type: 'sqlite',
logging: true,
entities: Object.values(entities),
database: path.resolve(UserSettings.getUserN8nFolderPath(), 'database.sqlite'),
migrations: [path.resolve(MIGRATIONS_DIR, 'sqlite', 'index.ts')],
cli: {
entitiesDir: ENTITIES_DIR,
migrationsDir: path.resolve(MIGRATIONS_DIR, 'sqlite'),
},
},
{
name: 'postgres',
type: 'postgres',
database: 'n8n',
schema: 'public',
username: 'postgres',
password: '',
host: 'localhost',
port: 5432,
logging: false,
entities: Object.values(entities),
migrations: [path.resolve(MIGRATIONS_DIR, 'postgresdb', 'index.ts')],
cli: {
entitiesDir: ENTITIES_DIR,
migrationsDir: path.resolve(MIGRATIONS_DIR, 'postgresdb'),
},
},
{
name: 'mysql',
type: 'mysql',
database: 'n8n',
username: 'root',
password: 'password',
host: 'localhost',
port: 3306,
logging: false,
entities: Object.values(entities),
migrations: [path.resolve(MIGRATIONS_DIR, 'mysqldb', 'index.ts')],
cli: {
entitiesDir: ENTITIES_DIR,
migrationsDir: path.resolve(MIGRATIONS_DIR, 'mysqldb'),
},
},
{
name: 'mariadb',
type: 'mariadb',
database: 'n8n',
username: 'root',
password: 'password',
host: 'localhost',
port: 3306,
logging: false,
entities: Object.values(entities),
migrations: [path.resolve(MIGRATIONS_DIR, 'mysqldb', 'index.ts')],
cli: {
entitiesDir: ENTITIES_DIR,
migrationsDir: path.resolve(MIGRATIONS_DIR, 'mysqldb'),
},
},
getSqliteConnectionOptions(),
getPostgresConnectionOptions(),
getMysqlConnectionOptions(),
getMariaDBConnectionOptions(),
];