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

Function applyPgDiffs

drizzle-kit/tests/schemaDiffer.ts:1130–1212  ·  view source on GitHub ↗
(
	sn: PostgresSchema,
	casing: CasingType | undefined,
)

Source from the content-addressed store, hash-verified

1128};
1129
1130export const applyPgDiffs = async (
1131 sn: PostgresSchema,
1132 casing: CasingType | undefined,
1133) => {
1134 const dryRun = {
1135 version: '7',
1136 dialect: 'postgresql',
1137 id: '0',
1138 prevId: '0',
1139 tables: {},
1140 enums: {},
1141 views: {},
1142 schemas: {},
1143 sequences: {},
1144 policies: {},
1145 roles: {},
1146 _meta: {
1147 schemas: {},
1148 tables: {},
1149 columns: {},
1150 },
1151 } as const;
1152
1153 const tables = Object.values(sn).filter((it) => is(it, PgTable)) as PgTable[];
1154
1155 const schemas = Object.values(sn).filter((it) => is(it, PgSchema)) as PgSchema[];
1156
1157 const enums = Object.values(sn).filter((it) => isPgEnum(it)) as PgEnum<any>[];
1158
1159 const sequences = Object.values(sn).filter((it) => isPgSequence(it)) as PgSequence[];
1160
1161 const roles = Object.values(sn).filter((it) => is(it, PgRole)) as PgRole[];
1162
1163 const views = Object.values(sn).filter((it) => isPgView(it)) as PgView[];
1164
1165 const policies = Object.values(sn).filter((it) => is(it, PgPolicy)) as PgPolicy[];
1166
1167 const materializedViews = Object.values(sn).filter((it) => isPgMaterializedView(it)) as PgMaterializedView[];
1168
1169 const serialized1 = generatePgSnapshot(
1170 tables,
1171 enums,
1172 schemas,
1173 sequences,
1174 roles,
1175 policies,
1176 views,
1177 materializedViews,
1178 casing,
1179 );
1180
1181 const { version: v1, dialect: d1, ...rest1 } = serialized1;
1182
1183 const sch1 = {
1184 version: '7',
1185 dialect: 'postgresql',
1186 id: '0',
1187 prevId: '0',

Callers 2

diffTestSchemasPushFunction · 0.85
introspectPgToFileFunction · 0.85

Calls 15

isFunction · 0.90
isPgEnumFunction · 0.90
isPgSequenceFunction · 0.90
isPgViewFunction · 0.90
isPgMaterializedViewFunction · 0.90
generatePgSnapshotFunction · 0.90
squashPgSchemeFunction · 0.90
applyPgSnapshotsDiffFunction · 0.90
testSchemasResolverFunction · 0.85
testEnumsResolverFunction · 0.85
testSequencesResolverFunction · 0.85
testPolicyResolverFunction · 0.85

Tested by

no test coverage detected