MCPcopy
hub / github.com/drizzle-team/drizzle-orm / squashPgScheme

Function squashPgScheme

drizzle-kit/src/serializer/pgSchema.ts:758–868  ·  view source on GitHub ↗
(
	json: PgSchema,
	action?: 'push' | undefined,
)

Source from the content-addressed store, hash-verified

756};
757
758export 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,

Callers 10

generateMigrationFunction · 0.90
pushSchemaFunction · 0.90
introspectPostgresFunction · 0.90
prepareAndMigratePgFunction · 0.90
prepareAndExportPgFunction · 0.90
preparePgPushFunction · 0.90
diffTestSchemasPushFunction · 0.90
applyPgDiffsFunction · 0.90
diffTestSchemasFunction · 0.90
introspectPgToFileFunction · 0.90

Calls 1

mapValuesFunction · 0.90

Tested by

no test coverage detected