sql-mirror is an opinionated SQL migration generator that produces up/down SQL files from reusable raw SQL chunks. Version 0.4.1 is the latest stable release with no set release cadence. It focuses on consistency: automatically adds id columns using UUID v4, created_at/updated_at timestamps, and enforces topological ordering of tables based on foreign key references. Differentiators include a built-in trigger function for updated_at, zero runtime dependencies, and a JSON config output for version control.
npm install sql-mirrorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Generates up/down SQL migration files from a configuration object with table definitions.
Ensure all foreign key references point to existing tables defined in the same config.
Use a separate migration tool (e.g., pg-migrate, node-pg-migrate) to apply generated SQL.
Always include 'uuid-ossp' in the extensions array to generate UUID primaries.
Use lowercase table names to avoid double-quoting issues.
Install the package: npm install -D sql-mirror, and use ESM imports (import ... from 'sql-mirror').
Ensure import { sql } from 'sql-mirror' is present and package version >=0.4.0.Create the directory with mkdirSync('./migrations', { recursive: true }) before writing files.No dependency data recorded yet.