fix script
This commit is contained in:
parent
22fd9152bf
commit
0f4bee4489
1 changed files with 27 additions and 11 deletions
|
|
@ -7938,7 +7938,7 @@ export class OrganizationController extends Controller {
|
||||||
ancestorDNA: rootDnaId,
|
ancestorDNA: rootDnaId,
|
||||||
orgRevisionId: drafRevisionId,
|
orgRevisionId: drafRevisionId,
|
||||||
},
|
},
|
||||||
select: ["id"],
|
// select: ["id"],
|
||||||
}),
|
}),
|
||||||
this.orgRootRepository.findOne({
|
this.orgRootRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -7981,16 +7981,32 @@ export class OrganizationController extends Controller {
|
||||||
|
|
||||||
// Process from top (Root) to bottom (Child4) to handle foreign key constraints
|
// Process from top (Root) to bottom (Child4) to handle foreign key constraints
|
||||||
// OrgRoot (sync first - no parent dependencies)
|
// OrgRoot (sync first - no parent dependencies)
|
||||||
const orgRootResult = await this.syncOrgLevel(
|
// If we manually created orgRootCurrent, skip syncOrgLevel and set up mapping directly
|
||||||
queryRunner,
|
// to avoid double insert (syncOrgLevel would try to insert again because IDs don't match)
|
||||||
OrgRoot,
|
let orgRootResult: { mapping: OrgIdMapping; counts: { deleted: number; updated: number; inserted: number } };
|
||||||
this.orgRootRepository,
|
if (orgRootCurrent && orgRootDraft && orgRootCurrent.ancestorDNA === orgRootDraft.ancestorDNA) {
|
||||||
drafRevisionId,
|
// Manually created - set up mapping directly
|
||||||
currentRevisionId,
|
const rootMapping: OrgIdMapping = {
|
||||||
allMappings,
|
byAncestorDNA: new Map([[orgRootDraft.ancestorDNA, orgRootCurrent.id]]),
|
||||||
orgRootDraft?.id,
|
byDraftId: new Map([[orgRootDraft.id, orgRootCurrent.id]]),
|
||||||
orgRootCurrent?.id,
|
};
|
||||||
);
|
orgRootResult = {
|
||||||
|
mapping: rootMapping,
|
||||||
|
counts: { deleted: 0, updated: 0, inserted: 1 }, // Count as insert since we created it
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// Not manually created - use normal syncOrgLevel flow
|
||||||
|
orgRootResult = await this.syncOrgLevel(
|
||||||
|
queryRunner,
|
||||||
|
OrgRoot,
|
||||||
|
this.orgRootRepository,
|
||||||
|
drafRevisionId,
|
||||||
|
currentRevisionId,
|
||||||
|
allMappings,
|
||||||
|
orgRootDraft?.id,
|
||||||
|
orgRootCurrent?.id,
|
||||||
|
);
|
||||||
|
}
|
||||||
allMappings.orgRoot = orgRootResult.mapping;
|
allMappings.orgRoot = orgRootResult.mapping;
|
||||||
orgSyncStats.orgRoot = orgRootResult.counts;
|
orgSyncStats.orgRoot = orgRootResult.counts;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue