({
tableId,
oldField,
newField,
diffMap,
changedTables,
changedFields,
attributes,
changedTablesAttributes,
changedFieldsAttributes,
}: {
tableId: string;
oldField: DBField;
newField: DBField;
diffMap: DiffMap;
changedTables: Map<string, boolean>;
changedFields: Map<string, boolean>;
attributes?: FieldDiffAttribute[];
changedTablesAttributes?: TableDiffAttribute[];
changedFieldsAttributes?: FieldDiffAttribute[];
})
| 768 | |
| 769 | // Compare field properties |
| 770 | function compareFieldProperties({ |
| 771 | tableId, |
| 772 | oldField, |
| 773 | newField, |
| 774 | diffMap, |
| 775 | changedTables, |
| 776 | changedFields, |
| 777 | attributes, |
| 778 | changedTablesAttributes, |
| 779 | changedFieldsAttributes, |
| 780 | }: { |
| 781 | tableId: string; |
| 782 | oldField: DBField; |
| 783 | newField: DBField; |
| 784 | diffMap: DiffMap; |
| 785 | changedTables: Map<string, boolean>; |
| 786 | changedFields: Map<string, boolean>; |
| 787 | attributes?: FieldDiffAttribute[]; |
| 788 | changedTablesAttributes?: TableDiffAttribute[]; |
| 789 | changedFieldsAttributes?: FieldDiffAttribute[]; |
| 790 | }) { |
| 791 | // If attributes are specified, only check those attributes |
| 792 | const attributesToCheck: FieldDiffAttribute[] = attributes ?? [ |
| 793 | 'name', |
| 794 | 'type', |
| 795 | 'primaryKey', |
| 796 | 'unique', |
| 797 | 'nullable', |
| 798 | 'comments', |
| 799 | 'characterMaximumLength', |
| 800 | 'scale', |
| 801 | 'precision', |
| 802 | 'increment', |
| 803 | 'isArray', |
| 804 | ]; |
| 805 | |
| 806 | const changedAttributes: FieldDiffAttribute[] = []; |
| 807 | |
| 808 | if (attributesToCheck.includes('name') && oldField.name !== newField.name) { |
| 809 | changedAttributes.push('name'); |
| 810 | } |
| 811 | |
| 812 | if ( |
| 813 | attributesToCheck.includes('type') && |
| 814 | oldField.type.id !== newField.type.id |
| 815 | ) { |
| 816 | changedAttributes.push('type'); |
| 817 | } |
| 818 | |
| 819 | if ( |
| 820 | attributesToCheck.includes('primaryKey') && |
| 821 | oldField.primaryKey !== newField.primaryKey |
| 822 | ) { |
| 823 | changedAttributes.push('primaryKey'); |
| 824 | } |
| 825 | |
| 826 | if ( |
| 827 | attributesToCheck.includes('unique') && |
no test coverage detected