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

Function generateMigration

drizzle-kit/src/api.ts:94–123  ·  view source on GitHub ↗
(
	prev: DrizzleSnapshotJSON,
	cur: DrizzleSnapshotJSON,
)

Source from the content-addressed store, hash-verified

92};
93
94export const generateMigration = async (
95 prev: DrizzleSnapshotJSON,
96 cur: DrizzleSnapshotJSON,
97) => {
98 const { applyPgSnapshotsDiff } = await import('./snapshotsDiffer');
99
100 const validatedPrev = pgSchema.parse(prev);
101 const validatedCur = pgSchema.parse(cur);
102
103 const squashedPrev = squashPgScheme(validatedPrev);
104 const squashedCur = squashPgScheme(validatedCur);
105
106 const { sqlStatements, _meta } = await applyPgSnapshotsDiff(
107 squashedPrev,
108 squashedCur,
109 schemasResolver,
110 enumsResolver,
111 sequencesResolver,
112 policyResolver,
113 indPolicyResolver,
114 roleResolver,
115 tablesResolver,
116 columnsResolver,
117 viewsResolver,
118 validatedPrev,
119 validatedCur,
120 );
121
122 return sqlStatements;
123};
124
125export const pushSchema = async (
126 imports: Record<string, unknown>,

Callers

nothing calls this directly

Calls 2

squashPgSchemeFunction · 0.90
applyPgSnapshotsDiffFunction · 0.85

Tested by

no test coverage detected