({
diagram,
newDiagram,
diffMap,
changedTables,
changedFields,
changedIndexes,
changedCheckConstraints,
options,
changedTablesAttributes,
changedFieldsAttributes,
changedIndexesAttributes,
changedCheckConstraintsAttributes,
tableMatcher,
fieldMatcher,
indexMatcher,
checkConstraintMatcher,
databaseType,
}: {
diagram: Diagram;
newDiagram: Diagram;
diffMap: DiffMap;
changedTables: Map<string, boolean>;
changedFields: Map<string, boolean>;
changedIndexes: Map<string, boolean>;
changedCheckConstraints: Map<string, boolean>;
options?: GenerateDiffOptions;
changedTablesAttributes?: TableDiffAttribute[];
changedFieldsAttributes?: FieldDiffAttribute[];
changedIndexesAttributes?: IndexDiffAttribute[];
changedCheckConstraintsAttributes?: CheckConstraintDiffAttribute[];
tableMatcher: (table: DBTable, tables: DBTable[]) => DBTable | undefined;
fieldMatcher: (field: DBField, fields: DBField[]) => DBField | undefined;
indexMatcher: (index: DBIndex, indexes: DBIndex[]) => DBIndex | undefined;
checkConstraintMatcher: (
constraint: DBCheckConstraint,
constraints: DBCheckConstraint[]
) => DBCheckConstraint | undefined;
databaseType: DatabaseType;
})
| 565 | |
| 566 | // Compare fields, indexes, and check constraints for matching tables |
| 567 | function compareTableContents({ |
| 568 | diagram, |
| 569 | newDiagram, |
| 570 | diffMap, |
| 571 | changedTables, |
| 572 | changedFields, |
| 573 | changedIndexes, |
| 574 | changedCheckConstraints, |
| 575 | options, |
| 576 | changedTablesAttributes, |
| 577 | changedFieldsAttributes, |
| 578 | changedIndexesAttributes, |
| 579 | changedCheckConstraintsAttributes, |
| 580 | tableMatcher, |
| 581 | fieldMatcher, |
| 582 | indexMatcher, |
| 583 | checkConstraintMatcher, |
| 584 | databaseType, |
| 585 | }: { |
| 586 | diagram: Diagram; |
| 587 | newDiagram: Diagram; |
| 588 | diffMap: DiffMap; |
| 589 | changedTables: Map<string, boolean>; |
| 590 | changedFields: Map<string, boolean>; |
| 591 | changedIndexes: Map<string, boolean>; |
| 592 | changedCheckConstraints: Map<string, boolean>; |
| 593 | options?: GenerateDiffOptions; |
| 594 | changedTablesAttributes?: TableDiffAttribute[]; |
| 595 | changedFieldsAttributes?: FieldDiffAttribute[]; |
| 596 | changedIndexesAttributes?: IndexDiffAttribute[]; |
| 597 | changedCheckConstraintsAttributes?: CheckConstraintDiffAttribute[]; |
| 598 | tableMatcher: (table: DBTable, tables: DBTable[]) => DBTable | undefined; |
| 599 | fieldMatcher: (field: DBField, fields: DBField[]) => DBField | undefined; |
| 600 | indexMatcher: (index: DBIndex, indexes: DBIndex[]) => DBIndex | undefined; |
| 601 | checkConstraintMatcher: ( |
| 602 | constraint: DBCheckConstraint, |
| 603 | constraints: DBCheckConstraint[] |
| 604 | ) => DBCheckConstraint | undefined; |
| 605 | databaseType: DatabaseType; |
| 606 | }) { |
| 607 | const oldTables = diagram.tables || []; |
| 608 | const newTables = newDiagram.tables || []; |
| 609 | |
| 610 | // For each table that exists in both diagrams |
| 611 | for (const oldTable of oldTables) { |
| 612 | const newTable = tableMatcher(oldTable, newTables); |
| 613 | if (!newTable) continue; |
| 614 | |
| 615 | // Compare fields |
| 616 | if (options?.includeFields) { |
| 617 | compareFields({ |
| 618 | tableId: oldTable.id, |
| 619 | oldFields: oldTable.fields, |
| 620 | newFields: newTable.fields, |
| 621 | diffMap, |
| 622 | changedTables, |
| 623 | changedFields, |
| 624 | attributes: options?.attributes?.fields, |
no test coverage detected