33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import db from '../src/database/models/index.js';
|
|
import { ParticipantService } from '../src/services/ParticipantService.js';
|
|
|
|
async function hardReset() {
|
|
console.log('Starting Hard Reset: Standardizing F&F Participants to 8 National Roles...');
|
|
|
|
try {
|
|
// 1. Wipe ALL participants for F&F requests
|
|
console.log('Wiping existing F&F participants...');
|
|
const deleteCount = await db.RequestParticipant.destroy({
|
|
where: { requestType: 'fnf' }
|
|
});
|
|
console.log(`Deleted ${deleteCount} legacy participant records.`);
|
|
|
|
// 2. Re-sync all F&F records using the new strict logic
|
|
const fnfs = await db.FnF.findAll({ attributes: ['id', 'settlementId'] });
|
|
console.log(`Resyncing ${fnfs.length} F&F settlements...`);
|
|
|
|
for (const fnf of fnfs) {
|
|
console.log(`Syncing ${fnf.settlementId}...`);
|
|
await ParticipantService.assignFnFParticipants(fnf.id);
|
|
}
|
|
|
|
console.log('\nHard Reset Complete! All F&F records are now limited to 8 National Roles.');
|
|
} catch (error) {
|
|
console.error('Error during hard reset:', error);
|
|
} finally {
|
|
process.exit();
|
|
}
|
|
}
|
|
|
|
hardReset();
|