()
| 316 | }; |
| 317 | |
| 318 | const checkMigrationVersion = async () => { |
| 319 | const client = await pool.connect(); |
| 320 | |
| 321 | try { |
| 322 | const current = await getCurrentSchemaVersion(client); |
| 323 | |
| 324 | if (!current) { |
| 325 | logger.error(`❌ No schema version found in ${migrationTable}. Expected v${EXPECTED_SCHEMA_VERSION}.`); |
| 326 | process.exit(1); |
| 327 | } |
| 328 | |
| 329 | const currentVersion = Number(current.version); |
| 330 | if (currentVersion !== EXPECTED_SCHEMA_VERSION) { |
| 331 | logger.error( |
| 332 | `❌ Schema drift detected. Expected v${EXPECTED_SCHEMA_VERSION}, found v${currentVersion}.` |
| 333 | ); |
| 334 | process.exit(1); |
| 335 | } |
| 336 | |
| 337 | logger.info( |
| 338 | `✅ Schema version check passed (v${currentVersion}, label: ${current.label}).` |
| 339 | ); |
| 340 | } catch (error) { |
| 341 | logger.error('❌ Migration check failed:', error); |
| 342 | process.exit(1); |
| 343 | } finally { |
| 344 | client.release(); |
| 345 | await pool.end(); |
| 346 | } |
| 347 | }; |
| 348 | |
| 349 | const printMigrationStatus = async () => { |
| 350 | const client = await pool.connect(); |
no test coverage detected