26 lines
957 B
TypeScript
26 lines
957 B
TypeScript
import { CircuitListRepository } from "../src/db/repositories/circuit-list.repository.js";
|
|
import { CircuitSectionRepository } from "../src/db/repositories/circuit-section.repository.js";
|
|
import { ProjectRepository } from "../src/db/repositories/project.repository.js";
|
|
|
|
const projectRepository = new ProjectRepository();
|
|
const circuitListRepository = new CircuitListRepository();
|
|
const circuitSectionRepository = new CircuitSectionRepository();
|
|
|
|
async function run() {
|
|
const projects = await projectRepository.list();
|
|
let totalLists = 0;
|
|
for (const project of projects) {
|
|
const lists = await circuitListRepository.listByProject(project.id);
|
|
for (const list of lists) {
|
|
await circuitSectionRepository.createDefaults(list.id);
|
|
totalLists += 1;
|
|
}
|
|
}
|
|
console.log(`Section backfill done for ${totalLists} circuit list(s).`);
|
|
}
|
|
|
|
run().catch((error) => {
|
|
console.error("Section backfill failed:", error);
|
|
process.exit(1);
|
|
});
|