Skip to content

Commit bc6b247

Browse files
committed
fix: route SQLite pragma warnings to version logs
Pass the V1 and V2 loggers into the shared SQLite tuning helper so any best-effort setup warning lands with the matching database logs.
1 parent f48d463 commit bc6b247

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/database/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ if (nodeEnv === 'test') {
4141
}
4242

4343
export const sequelize = new Sequelize(config[dbConfigKey]);
44-
installSqlitePragmas(sequelize);
44+
installSqlitePragmas(sequelize, logger);
4545

4646
const mirrorConfig =
4747
(process.env.NODE_ENV || 'local') === 'local' ? 'mirror' : 'mirrorTest';
4848
export const sequelizeMirror = new Sequelize(config[mirrorConfig]);
49-
installSqlitePragmas(sequelizeMirror);
49+
installSqlitePragmas(sequelizeMirror, logger);
5050

5151
// Snapshot of whether V1 MIRROR_DB was fully configured at module-load time.
5252
// Captured alongside sequelizeMirror construction so mirrorDBEnabled() stays

src/database/sqlite-pragmas.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { logger } from '../config/logger.js';
2-
31
const SQLITE_PRAGMAS = [
42
'PRAGMA journal_mode = WAL',
53
'PRAGMA synchronous = NORMAL',
@@ -24,7 +22,7 @@ const applySqlitePragmas = async (connection) => {
2422
});
2523
};
2624

27-
export const installSqlitePragmas = (sequelize) => {
25+
export const installSqlitePragmas = (sequelize, pragmaLogger = console) => {
2826
if (sequelize.getDialect() !== 'sqlite') {
2927
return;
3028
}
@@ -42,7 +40,7 @@ export const installSqlitePragmas = (sequelize) => {
4240
configuredConnections.add(connection);
4341
} catch (error) {
4442
const message = error instanceof Error ? error.message : String(error);
45-
logger.warn(`Could not apply SQLite PRAGMAs: ${message}`);
43+
pragmaLogger.warn(`Could not apply SQLite PRAGMAs: ${message}`);
4644
}
4745
}
4846

src/database/v2/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ if (nodeEnv === 'test') {
4040
}
4141

4242
export const sequelizeV2 = new Sequelize(config[dbConfigKey]);
43-
installSqlitePragmas(sequelizeV2);
43+
installSqlitePragmas(sequelizeV2, loggerV2);
4444

4545
// Determine if MySQL mirror is configured by checking the actual config values
4646
// This allows MySQL mirror to work in any environment (local, test, production)
@@ -82,7 +82,7 @@ const isMysqlMirrorConfiguredForReconnectV2 = () => {
8282
};
8383

8484
export const sequelizeV2Mirror = new Sequelize(config[mirrorConfig]);
85-
installSqlitePragmas(sequelizeV2Mirror);
85+
installSqlitePragmas(sequelizeV2Mirror, loggerV2);
8686

8787
// Snapshot of "is the mirror Sequelize instance actually pointing at MySQL"
8888
// taken at module-load time, alongside sequelizeV2Mirror construction.

0 commit comments

Comments
 (0)