Skip to content

Pipeline

import { runAll, runPre, runMigrate, runPost, runValidate, runBaseline, runPipeline } from '@smplcty/schema-flow';
// Full pipeline: pre -> migrate -> post
const result = await runAll(config, logger);
// Individual phases
await runPre(config, logger);
await runMigrate(config, logger);
await runPost(config, logger);
// Validate: runs in a rolled-back transaction
await runValidate(config, logger);
// Baseline: record current files without running migrations
await runBaseline(config, logger);
const result = await runPipeline(config, logger, {
phaseFilter: 'migrate', // 'pre' | 'migrate' | 'post'
validateOnly: true, // execute in rolled-back transaction
});
interface ExecuteResult {
success: boolean;
operationsExecuted: number;
errors: string[];
}
interface BaselineResult {
filesRecorded: number;
}
import { buildPlan } from '@smplcty/schema-flow';
const plan = buildPlan(desired, actual, {
allowDestructive: false,
pgSchema: 'public',
});
console.log(`${plan.operations.length} operations`);
console.log(`${plan.blocked.length} blocked (destructive)`);
interface Operation {
type: OperationType;
objectName: string;
sql: string;
phase: number;
concurrent?: boolean;
}
import { discoverSchemaFiles, parseSchemaFile } from '@smplcty/schema-flow';
import { readFile } from 'node:fs/promises';
const discovered = await discoverSchemaFiles('./schema');
for (const file of discovered.schema) {
const content = await readFile(file.absolutePath, 'utf-8');
const parsed = parseSchemaFile(content);
// parsed.kind: 'table' | 'enum' | 'function' | 'view' | ...
// parsed.schema: the typed schema object
}
import {
parseTable,
parseEnum,
parseFunction,
parseView,
parseRole,
parseExtensions,
parseMixin,
parseTableFile,
parseFunctionFile,
parseEnumFile,
parseViewFile,
parseRoleFile,
} from '@smplcty/schema-flow';
import { loadMixins, applyMixins } from '@smplcty/schema-flow';
const registry = loadMixins(mixinSchemas);
const expandedTable = applyMixins(tableSchema, registry);
import { getStatus } from '@smplcty/schema-flow';
const status = await getStatus(config, logger);
console.log(`Applied: ${status.appliedFiles}, Pending: ${status.pendingChanges}`);
// status.history: { filePath, phase, appliedAt }[]