31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
|
|
import db from './src/database/models/index.js';
|
|
import { ParticipantService } from './src/services/ParticipantService';
|
|
|
|
async function syncAll() {
|
|
try {
|
|
const terminations = await db.TerminationRequest.findAll();
|
|
console.log(`Found ${terminations.length} terminations to sync...`);
|
|
|
|
for (const term of terminations) {
|
|
console.log(`Mapping participants for ${term.requestId} (${term.id})...`);
|
|
await ParticipantService.assignTerminationParticipants(term.id);
|
|
}
|
|
|
|
const changes = await db.ConstitutionalChange.findAll();
|
|
console.log(`Found ${changes.length} constitutional changes to sync...`);
|
|
for (const change of changes) {
|
|
console.log(`Mapping participants for ${change.requestId} (${change.id})...`);
|
|
await ParticipantService.assignConstitutionalParticipants(change.id);
|
|
}
|
|
|
|
console.log('Sync completed.');
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('Sync failed:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
syncAll();
|