Skip to content

API overview

Import from @smplcty/schema-flow for the main API, or @smplcty/schema-flow/testing for test helpers.

import { resolveConfig, createLogger } from '@smplcty/schema-flow';
const config = resolveConfig({
connectionString: process.env.DATABASE_URL,
baseDir: './schema',
pgSchema: 'public',
});
const logger = createLogger({ verbose: true, quiet: false, json: false });

All resolveConfig fields are optional. Without connectionString, it reads SCHEMA_FLOW_DATABASE_URL then DATABASE_URL from the environment.

FieldTypeDefaultDescription
connectionStringstringenv varsPostgreSQL connection string
baseDirstring'./schema'Root schema directory
pgSchemastring'public'Target PostgreSQL schema
dryRunbooleanfalsePlan only
allowDestructivebooleanfalseAllow destructive operations
skipChecksbooleanfalseSkip pre-migration checks
lockTimeoutnumber5000Lock timeout (ms)
statementTimeoutnumber30000Statement timeout (ms)
maxRetriesnumber3Retries on transient errors
historyTablestring'history'History table name
verbosebooleanfalseVerbose output
quietbooleanfalseSuppress non-error output
jsonbooleanfalseJSON output
import { resolveConfig, runAll, createLogger } from '@smplcty/schema-flow';
const config = resolveConfig({ connectionString: process.env.DATABASE_URL });
const logger = createLogger({ verbose: true });
const result = await runAll(config, logger);
console.log(`Executed ${result.operationsExecuted} operations`);