feat(core): Add an option to enable WAL mode for SQLite (#7118)

https://www.sqlite.org/wal.html
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-09-07 15:58:48 +02:00 committed by GitHub
parent 67aaad15eb
commit 1d1a022def
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View file

@ -164,6 +164,12 @@ export const schema = {
default: 'database.sqlite', default: 'database.sqlite',
env: 'DB_SQLITE_DATABASE', env: 'DB_SQLITE_DATABASE',
}, },
enableWAL: {
doc: 'Enable SQLite WAL mode',
format: Boolean,
default: false,
env: 'DB_SQLITE_ENABLE_WAL',
},
executeVacuumOnStartup: { executeVacuumOnStartup: {
doc: 'Runs VACUUM operation on startup to rebuild the database. Reduces filesize and optimizes indexes. WARNING: This is a long running blocking operation. Will increase start-up time.', doc: 'Runs VACUUM operation on startup to rebuild the database. Reduces filesize and optimizes indexes. WARNING: This is a long running blocking operation. Will increase start-up time.',
format: Boolean, format: Boolean,

View file

@ -24,6 +24,7 @@ const getDBConnectionOptions = (dbType: DatabaseType) => {
UserSettings.getUserN8nFolderPath(), UserSettings.getUserN8nFolderPath(),
config.getEnv('database.sqlite.database'), config.getEnv('database.sqlite.database'),
), ),
enableWAL: config.getEnv('database.sqlite.enableWAL'),
} }
: { : {
database: config.getEnv(`database.${configDBType}.database`), database: config.getEnv(`database.${configDBType}.database`),

View file

@ -576,7 +576,7 @@ export async function getVariableById(id: string) {
* Generate options for an in-memory sqlite database connection, * Generate options for an in-memory sqlite database connection,
* one per test suite run. * one per test suite run.
*/ */
export const getSqliteOptions = ({ name }: { name: string }): ConnectionOptions => { const getSqliteOptions = ({ name }: { name: string }): ConnectionOptions => {
return { return {
name, name,
type: 'sqlite', type: 'sqlite',
@ -586,6 +586,7 @@ export const getSqliteOptions = ({ name }: { name: string }): ConnectionOptions
migrations: sqliteMigrations, migrations: sqliteMigrations,
migrationsTableName: 'migrations', migrationsTableName: 'migrations',
migrationsRun: false, migrationsRun: false,
enableWAL: config.getEnv('database.sqlite.enableWAL'),
}; };
}; };