Skip to content

Commit

Permalink
feat(core): Add an option to enable WAL mode for SQLite (#7118)
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy authored Sep 7, 2023
1 parent 67aaad1 commit 1d1a022
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/cli/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/databases/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`),
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/test/integration/shared/testDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -586,6 +586,7 @@ export const getSqliteOptions = ({ name }: { name: string }): ConnectionOptions
migrations: sqliteMigrations,
migrationsTableName: 'migrations',
migrationsRun: false,
enableWAL: config.getEnv('database.sqlite.enableWAL'),
};
};

Expand Down

0 comments on commit 1d1a022

Please sign in to comment.