feat: improve move-draft-to-current with differential sync
Implement differential sync for organization structure and positions instead of delete-all-and-insert-all approach. Changes: - Add OrgIdMapping and AllOrgMappings interfaces for tracking ID mappings - Implement syncOrgLevel() helper for differential sync per org level - Add syncPositionsForPosMaster() helper for position table sync - Process org levels bottom-up (Child4→Child3→Child2→Child1→Root) - Use ancestorDNA matching with Like operator for descendant sync - Cascade delete positions before deleting org nodes - Batch DELETE/UPDATE/INSERT operations for better performance - Track draft→current ID mappings for position updates - Add comprehensive documentation in docs/move-draft-to-current.md Benefits: - Preserve IDs for unchanged nodes (better tracking) - More efficient (fewer database operations) - Better data integrity with proper FK handling - Sync all descendants under given rootDnaId Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
22fc43fe17
commit
638362df1c
3 changed files with 938 additions and 24 deletions
24
src/interfaces/OrgMapping.ts
Normal file
24
src/interfaces/OrgMapping.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Type definitions for organization mapping used in move-draft-to-current function
|
||||
*/
|
||||
|
||||
/**
|
||||
* Maps draft organization IDs to current organization IDs
|
||||
* - byAncestorDNA: Maps ancestorDNA to current ID for lookup
|
||||
* - byDraftId: Maps draft ID to current ID for position updates
|
||||
*/
|
||||
export interface OrgIdMapping {
|
||||
byAncestorDNA: Map<string, string>;
|
||||
byDraftId: Map<string, string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains mappings for all organization levels
|
||||
*/
|
||||
export interface AllOrgMappings {
|
||||
orgRoot: OrgIdMapping;
|
||||
orgChild1: OrgIdMapping;
|
||||
orgChild2: OrgIdMapping;
|
||||
orgChild3: OrgIdMapping;
|
||||
orgChild4: OrgIdMapping;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue