Skip to content

Commit

Permalink
Merge pull request #170 from Chia-Network/enable-sqlite-wal-mode
Browse files Browse the repository at this point in the history
feat: enable sqlite WAL mode
  • Loading branch information
TheLastCicada authored Jan 15, 2025
2 parents a3d733b + 31dbde9 commit fa575ab
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/database/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash';
import { Sequelize } from 'sequelize';
import { QueryTypes, Sequelize } from 'sequelize';
import config from '../config/config.js';
import { logger } from '../logger.js';
import mysql from 'mysql2/promise';
Expand Down Expand Up @@ -158,3 +158,17 @@ export const prepareDb = async () => {

await checkForMigrations(sequelize);
};

// Function to set WAL mode
async function setWALMode() {
try {
await sequelize.authenticate();

await sequelize.query('PRAGMA journal_mode=WAL;', { type: QueryTypes.RAW });
console.log('WAL mode set successfully.');
} catch (error) {
console.error('Unable to set WAL mode:', error);
}
}

setWALMode();

0 comments on commit fa575ab

Please sign in to comment.