Files
gamercomp/backend/scripts/rollback-touch-fix.js
T
2026-04-30 02:14:25 +00:00

62 lines
1.6 KiB
JavaScript
Executable File

#!/usr/bin/env node
/**
* Rollback the touch handling fixes - restore original game code
*/
require('dotenv').config({ path: require('path').join(__dirname, '../.env') });
const { Pool } = require('pg');
const pool = new Pool({
host: process.env.DB_HOST || 'localhost',
port: parseInt(process.env.DB_PORT || '5432'),
database: process.env.DB_NAME || 'game_arcade',
user: process.env.DB_USER || 'gamearc',
password: process.env.DB_PASSWORD
});
async function main() {
console.log('Rolling back touch handling fixes...\n');
// Find all games that were "fixed" and have a version to restore from
const result = await pool.query(`
SELECT gv.game_id, gv.game_code, g.title
FROM game_versions gv
JOIN games g ON g.id = gv.game_id
WHERE gv.change_type = 'fix'
AND gv.change_description LIKE '%touch handling%'
ORDER BY gv.game_id
`);
console.log(`Found ${result.rows.length} games to rollback\n`);
for (const row of result.rows) {
console.log(`[${row.game_id}] ${row.title}`);
// Restore the original code
await pool.query(
'UPDATE games SET game_code = $1, code_updated_at = NOW() WHERE id = $2',
[row.game_code, row.game_id]
);
// Delete the fix version from history
await pool.query(
`DELETE FROM game_versions
WHERE game_id = $1
AND change_type = 'fix'
AND change_description LIKE '%touch handling%'`,
[row.game_id]
);
console.log(' ✓ Restored original code');
}
console.log('\nRollback complete!');
await pool.end();
}
main().catch(err => {
console.error('Error:', err);
process.exit(1);
});