← back to Tk 11331 Exec
d3b_heldreview_rollback.mjs
19 lines
#!/usr/bin/env node
// TK-11331 D3b-heldreview ROLLBACK — removes the 79 staged held colorways (ids 61900..61978).
// Reversible undo for the d3b-heldreview-stage op. Dry-run by default; --apply to execute.
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const { Pool } = require('pg');
const APPLY = process.argv.includes('--apply');
const pool = new Pool({ host: '/tmp', database: 'dw_unified' });
const LO = 61900, HI = 61978;
async function main() {
const { rows } = await pool.query('SELECT count(*)::int n FROM momentum_colorways WHERE id BETWEEN $1 AND $2', [LO, HI]);
console.log(`rows in range ${LO}-${HI}: ${rows[0].n}`);
if (!APPLY) { console.log('DRY-RUN. Re-run with --apply to remove them.'); await pool.end(); return; }
const r = await pool.query('DELETE FROM momentum_colorways WHERE id BETWEEN $1 AND $2', [LO, HI]);
console.log(`removed ${r.rowCount} rows.`);
await pool.end();
}
main().catch(e => { console.error(e); process.exit(1); });