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

Function prepareAndExportPg

drizzle-kit/src/cli/commands/migrate.ts:371–407  ·  view source on GitHub ↗
(config: ExportConfig)

Source from the content-addressed store, hash-verified

369};
370
371export const prepareAndExportPg = async (config: ExportConfig) => {
372 const schemaPath = config.schema;
373
374 try {
375 const { prev, cur } = await preparePgMigrationSnapshot(
376 [], // no snapshots before
377 schemaPath,
378 undefined,
379 );
380
381 const validatedPrev = pgSchema.parse(prev);
382 const validatedCur = pgSchema.parse(cur);
383
384 const squashedPrev = squashPgScheme(validatedPrev);
385 const squashedCur = squashPgScheme(validatedCur);
386
387 const { sqlStatements } = await applyPgSnapshotsDiff(
388 squashedPrev,
389 squashedCur,
390 schemasResolver,
391 enumsResolver,
392 sequencesResolver,
393 policyResolver,
394 indPolicyResolver,
395 roleResolver,
396 tablesResolver,
397 columnsResolver,
398 viewsResolver,
399 validatedPrev,
400 validatedCur,
401 );
402
403 console.log(sqlStatements.join('\n'));
404 } catch (e) {
405 console.error(e);
406 }
407};
408
409export const preparePgPush = async (
410 cur: PgSchema,

Callers 1

schema.tsFile · 0.85

Calls 3

squashPgSchemeFunction · 0.90
applyPgSnapshotsDiffFunction · 0.90

Tested by

no test coverage detected