mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 21:07:28 -08:00
✨ Make it possible to define prefix for table names
This commit is contained in:
parent
4469e9bb8f
commit
255d30b2c7
|
@ -4,6 +4,13 @@ By default, n8n uses SQLite to save credentials, past executions, and workflows.
|
|||
n8n however also supports MongoDB and PostgresDB.
|
||||
|
||||
|
||||
## Shared Settings
|
||||
|
||||
The following environment variables get used by all databases:
|
||||
|
||||
- `DB_TABLE_PREFIX` (default: '') - Prefix for table names
|
||||
|
||||
|
||||
## MongoDB
|
||||
|
||||
!> **WARNING**: Use Postgres if possible! Mongo has problems with saving large
|
||||
|
|
|
@ -20,6 +20,12 @@ const config = convict({
|
|||
env: 'DB_MONGODB_CONNECTION_URL'
|
||||
}
|
||||
},
|
||||
tablePrefix: {
|
||||
doc: 'Prefix for table names',
|
||||
format: '*',
|
||||
default: '',
|
||||
env: 'DB_TABLE_PREFIX'
|
||||
},
|
||||
postgresdb: {
|
||||
database: {
|
||||
doc: 'PostgresDB Database',
|
||||
|
|
|
@ -42,6 +42,7 @@ export async function init(synchronize?: boolean): Promise<IDatabaseCollections>
|
|||
entities = MongoDb;
|
||||
connectionOptions = {
|
||||
type: 'mongodb',
|
||||
entityPrefix: await GenericHelpers.getConfigValue('database.tablePrefix') as string,
|
||||
url: await GenericHelpers.getConfigValue('database.mongodb.connectionUrl') as string,
|
||||
useNewUrlParser: true,
|
||||
};
|
||||
|
@ -52,6 +53,7 @@ export async function init(synchronize?: boolean): Promise<IDatabaseCollections>
|
|||
entities = PostgresDb;
|
||||
connectionOptions = {
|
||||
type: 'postgres',
|
||||
entityPrefix: await GenericHelpers.getConfigValue('database.tablePrefix') as string,
|
||||
database: await GenericHelpers.getConfigValue('database.postgresdb.database') as string,
|
||||
host: await GenericHelpers.getConfigValue('database.postgresdb.host') as string,
|
||||
password: await GenericHelpers.getConfigValue('database.postgresdb.password') as string,
|
||||
|
@ -67,10 +69,11 @@ export async function init(synchronize?: boolean): Promise<IDatabaseCollections>
|
|||
connectionOptions = {
|
||||
type: 'mysql',
|
||||
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,
|
||||
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
|
||||
username: await GenericHelpers.getConfigValue('database.mysqldb.user') as string,
|
||||
};
|
||||
break;
|
||||
|
||||
|
@ -80,6 +83,7 @@ export async function init(synchronize?: boolean): Promise<IDatabaseCollections>
|
|||
connectionOptions = {
|
||||
type: 'sqlite',
|
||||
database: path.join(n8nFolder, 'database.sqlite'),
|
||||
entityPrefix: await GenericHelpers.getConfigValue('database.tablePrefix') as string,
|
||||
};
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue