From 1d1a022defefc790905cfb8fcb9dd364ffb063bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Thu, 7 Sep 2023 15:58:48 +0200 Subject: [PATCH] feat(core): Add an option to enable WAL mode for SQLite (#7118) https://www.sqlite.org/wal.html --- packages/cli/src/config/schema.ts | 6 ++++++ packages/cli/src/databases/config.ts | 1 + packages/cli/test/integration/shared/testDb.ts | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/config/schema.ts b/packages/cli/src/config/schema.ts index 622f740aa7..a1df4f5116 100644 --- a/packages/cli/src/config/schema.ts +++ b/packages/cli/src/config/schema.ts @@ -164,6 +164,12 @@ export const schema = { default: 'database.sqlite', env: 'DB_SQLITE_DATABASE', }, + enableWAL: { + doc: 'Enable SQLite WAL mode', + format: Boolean, + default: false, + env: 'DB_SQLITE_ENABLE_WAL', + }, 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.', format: Boolean, diff --git a/packages/cli/src/databases/config.ts b/packages/cli/src/databases/config.ts index b496ea5bcf..a8e42da625 100644 --- a/packages/cli/src/databases/config.ts +++ b/packages/cli/src/databases/config.ts @@ -24,6 +24,7 @@ const getDBConnectionOptions = (dbType: DatabaseType) => { UserSettings.getUserN8nFolderPath(), config.getEnv('database.sqlite.database'), ), + enableWAL: config.getEnv('database.sqlite.enableWAL'), } : { database: config.getEnv(`database.${configDBType}.database`), diff --git a/packages/cli/test/integration/shared/testDb.ts b/packages/cli/test/integration/shared/testDb.ts index 3186c3f64b..4a9bd306bc 100644 --- a/packages/cli/test/integration/shared/testDb.ts +++ b/packages/cli/test/integration/shared/testDb.ts @@ -576,7 +576,7 @@ export async function getVariableById(id: string) { * Generate options for an in-memory sqlite database connection, * one per test suite run. */ -export const getSqliteOptions = ({ name }: { name: string }): ConnectionOptions => { +const getSqliteOptions = ({ name }: { name: string }): ConnectionOptions => { return { name, type: 'sqlite', @@ -586,6 +586,7 @@ export const getSqliteOptions = ({ name }: { name: string }): ConnectionOptions migrations: sqliteMigrations, migrationsTableName: 'migrations', migrationsRun: false, + enableWAL: config.getEnv('database.sqlite.enableWAL'), }; };