mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 05:17: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.
|
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
|
## MongoDB
|
||||||
|
|
||||||
!> **WARNING**: Use Postgres if possible! Mongo has problems with saving large
|
!> **WARNING**: Use Postgres if possible! Mongo has problems with saving large
|
||||||
|
|
|
@ -20,6 +20,12 @@ const config = convict({
|
||||||
env: 'DB_MONGODB_CONNECTION_URL'
|
env: 'DB_MONGODB_CONNECTION_URL'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
tablePrefix: {
|
||||||
|
doc: 'Prefix for table names',
|
||||||
|
format: '*',
|
||||||
|
default: '',
|
||||||
|
env: 'DB_TABLE_PREFIX'
|
||||||
|
},
|
||||||
postgresdb: {
|
postgresdb: {
|
||||||
database: {
|
database: {
|
||||||
doc: 'PostgresDB Database',
|
doc: 'PostgresDB Database',
|
||||||
|
|
|
@ -42,6 +42,7 @@ export async function init(synchronize?: boolean): Promise<IDatabaseCollections>
|
||||||
entities = MongoDb;
|
entities = MongoDb;
|
||||||
connectionOptions = {
|
connectionOptions = {
|
||||||
type: 'mongodb',
|
type: 'mongodb',
|
||||||
|
entityPrefix: await GenericHelpers.getConfigValue('database.tablePrefix') as string,
|
||||||
url: await GenericHelpers.getConfigValue('database.mongodb.connectionUrl') as string,
|
url: await GenericHelpers.getConfigValue('database.mongodb.connectionUrl') as string,
|
||||||
useNewUrlParser: true,
|
useNewUrlParser: true,
|
||||||
};
|
};
|
||||||
|
@ -52,6 +53,7 @@ export async function init(synchronize?: boolean): Promise<IDatabaseCollections>
|
||||||
entities = PostgresDb;
|
entities = PostgresDb;
|
||||||
connectionOptions = {
|
connectionOptions = {
|
||||||
type: 'postgres',
|
type: 'postgres',
|
||||||
|
entityPrefix: await GenericHelpers.getConfigValue('database.tablePrefix') as string,
|
||||||
database: await GenericHelpers.getConfigValue('database.postgresdb.database') as string,
|
database: await GenericHelpers.getConfigValue('database.postgresdb.database') as string,
|
||||||
host: await GenericHelpers.getConfigValue('database.postgresdb.host') as string,
|
host: await GenericHelpers.getConfigValue('database.postgresdb.host') as string,
|
||||||
password: await GenericHelpers.getConfigValue('database.postgresdb.password') as string,
|
password: await GenericHelpers.getConfigValue('database.postgresdb.password') as string,
|
||||||
|
@ -67,10 +69,11 @@ export async function init(synchronize?: boolean): Promise<IDatabaseCollections>
|
||||||
connectionOptions = {
|
connectionOptions = {
|
||||||
type: 'mysql',
|
type: 'mysql',
|
||||||
database: await GenericHelpers.getConfigValue('database.mysqldb.database') as string,
|
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,
|
host: await GenericHelpers.getConfigValue('database.mysqldb.host') as string,
|
||||||
password: await GenericHelpers.getConfigValue('database.mysqldb.password') as string,
|
password: await GenericHelpers.getConfigValue('database.mysqldb.password') as string,
|
||||||
port: await GenericHelpers.getConfigValue('database.mysqldb.port') as number,
|
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;
|
break;
|
||||||
|
|
||||||
|
@ -80,6 +83,7 @@ export async function init(synchronize?: boolean): Promise<IDatabaseCollections>
|
||||||
connectionOptions = {
|
connectionOptions = {
|
||||||
type: 'sqlite',
|
type: 'sqlite',
|
||||||
database: path.join(n8nFolder, 'database.sqlite'),
|
database: path.join(n8nFolder, 'database.sqlite'),
|
||||||
|
entityPrefix: await GenericHelpers.getConfigValue('database.tablePrefix') as string,
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue