fix: script insert
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m23s

This commit is contained in:
Warunee Tamkoo 2026-02-12 18:18:29 +07:00
parent 0f4bee4489
commit d555c70af9

View file

@ -7983,8 +7983,15 @@ export class OrganizationController extends Controller {
// OrgRoot (sync first - no parent dependencies) // OrgRoot (sync first - no parent dependencies)
// If we manually created orgRootCurrent, skip syncOrgLevel and set up mapping directly // If we manually created orgRootCurrent, skip syncOrgLevel and set up mapping directly
// to avoid double insert (syncOrgLevel would try to insert again because IDs don't match) // to avoid double insert (syncOrgLevel would try to insert again because IDs don't match)
let orgRootResult: { mapping: OrgIdMapping; counts: { deleted: number; updated: number; inserted: number } }; let orgRootResult: {
if (orgRootCurrent && orgRootDraft && orgRootCurrent.ancestorDNA === orgRootDraft.ancestorDNA) { mapping: OrgIdMapping;
counts: { deleted: number; updated: number; inserted: number };
};
if (
orgRootCurrent &&
orgRootDraft &&
orgRootCurrent.ancestorDNA === orgRootDraft.ancestorDNA
) {
// Manually created - set up mapping directly // Manually created - set up mapping directly
const rootMapping: OrgIdMapping = { const rootMapping: OrgIdMapping = {
byAncestorDNA: new Map([[orgRootDraft.ancestorDNA, orgRootCurrent.id]]), byAncestorDNA: new Map([[orgRootDraft.ancestorDNA, orgRootCurrent.id]]),
@ -8479,7 +8486,7 @@ export class OrganizationController extends Controller {
for (const draft of toInsert) { for (const draft of toInsert) {
const newNode: any = queryRunner.manager.create(entityClass, { const newNode: any = queryRunner.manager.create(entityClass, {
...draft, ...draft,
id: draft.id, id: undefined,
orgRevisionId: currentRevisionId, orgRevisionId: currentRevisionId,
}); });