( json: PgSchema, action?: 'push' | undefined, )
| 756 | }; |
| 757 | |
| 758 | export const squashPgScheme = ( |
| 759 | json: PgSchema, |
| 760 | action?: 'push' | undefined, |
| 761 | ): PgSchemaSquashed => { |
| 762 | const mappedTables = Object.fromEntries( |
| 763 | Object.entries(json.tables).map((it) => { |
| 764 | const squashedIndexes = mapValues(it[1].indexes, (index) => { |
| 765 | return action === 'push' |
| 766 | ? PgSquasher.squashIdxPush(index) |
| 767 | : PgSquasher.squashIdx(index); |
| 768 | }); |
| 769 | |
| 770 | const squashedFKs = mapValues(it[1].foreignKeys, (fk) => { |
| 771 | return PgSquasher.squashFK(fk); |
| 772 | }); |
| 773 | |
| 774 | const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => { |
| 775 | return PgSquasher.squashPK(pk); |
| 776 | }); |
| 777 | |
| 778 | const mappedColumns = Object.fromEntries( |
| 779 | Object.entries(it[1].columns).map((it) => { |
| 780 | const mappedIdentity = it[1].identity |
| 781 | ? PgSquasher.squashIdentity(it[1].identity) |
| 782 | : undefined; |
| 783 | return [ |
| 784 | it[0], |
| 785 | { |
| 786 | ...it[1], |
| 787 | identity: mappedIdentity, |
| 788 | }, |
| 789 | ]; |
| 790 | }), |
| 791 | ); |
| 792 | |
| 793 | const squashedUniqueConstraints = mapValues( |
| 794 | it[1].uniqueConstraints, |
| 795 | (unq) => { |
| 796 | return PgSquasher.squashUnique(unq); |
| 797 | }, |
| 798 | ); |
| 799 | |
| 800 | const squashedPolicies = mapValues(it[1].policies, (policy) => { |
| 801 | return action === 'push' |
| 802 | ? PgSquasher.squashPolicyPush(policy) |
| 803 | : PgSquasher.squashPolicy(policy); |
| 804 | }); |
| 805 | const squashedChecksContraints = mapValues( |
| 806 | it[1].checkConstraints, |
| 807 | (check) => { |
| 808 | return PgSquasher.squashCheck(check); |
| 809 | }, |
| 810 | ); |
| 811 | |
| 812 | return [ |
| 813 | it[0], |
| 814 | { |
| 815 | name: it[1].name, |
no test coverage detected