Time unification
This commit is contained in:
@@ -58,7 +58,12 @@ async function setupConnections(sshConfig) {
|
||||
"SELECT TIMESTAMPDIFF(SECOND, NOW(), UTC_TIMESTAMP()) as utcDiffSec"
|
||||
);
|
||||
const mysqlOffsetMs = -utcDiffSec * 1000; // MySQL UTC offset in ms (e.g., -21600000 for CST)
|
||||
const driverOffsetMs = -5 * 3600 * 1000; // Driver's -05:00 in ms (-18000000)
|
||||
// Driver offset from the actual config (e.g. '-06:00' in winter, '-05:00'
|
||||
// in summer — set dynamically in import-from-prod.js).
|
||||
const tzMatch = /^([+-])(\d{2}):(\d{2})$/.exec(sshConfig.prodDbConfig.timezone || '');
|
||||
const driverOffsetMs = tzMatch
|
||||
? (tzMatch[1] === '-' ? -1 : 1) * (Number(tzMatch[2]) * 3600 + Number(tzMatch[3]) * 60) * 1000
|
||||
: -5 * 3600 * 1000;
|
||||
const tzCorrectionMs = driverOffsetMs - mysqlOffsetMs;
|
||||
// CST (winter): -18000000 - (-21600000) = +3600000 (1 hour correction needed)
|
||||
// CDT (summer): -18000000 - (-18000000) = 0 (no correction needed)
|
||||
@@ -79,8 +84,13 @@ async function setupConnections(sshConfig) {
|
||||
}
|
||||
prodConnection.adjustDateForMySQL = adjustDateForMySQL;
|
||||
|
||||
// Setup PostgreSQL connection pool for local
|
||||
const localPool = new Pool(sshConfig.localDbConfig);
|
||||
// Setup PostgreSQL connection pool for local.
|
||||
// Pin the session timezone to business time (see docs/TIME.md) so import
|
||||
// writes and any CURRENT_DATE/NOW()::date logic mean Chicago dates.
|
||||
const localPool = new Pool({
|
||||
options: '-c TimeZone=America/Chicago',
|
||||
...sshConfig.localDbConfig,
|
||||
});
|
||||
|
||||
// Test the PostgreSQL connection
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user