Registry / database / migratrom

migratrom

JSON →
library0.0.4jsnpmunverified

Declarative, self-verifying schema migrations for PostgreSQL and SQLite, targeting Bun, Node (>=18), and Deno. Current stable version: 0.0.4, under active development with no release cadence defined yet. Key differentiator: driver-independent core with explicit dialects (PostgresDialect, SQLiteDialect), chain-based operation definitions, and built-in migration integrity checks using parent-child IDs. Uses optional peer drivers postgres and libsql.

npm install migratrom
INSTALL
IMPORT
SIG · MIGRATROM
M
migratrom
databasejavascriptv0.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

applyMigrations
import { applyMigrations } from 'migratrom'
const applyMigrations = require('migratrom')
ESM-only. CJS require will not work.
PostgresDialect
import { PostgresDialect } from 'migratrom'
import PostgresDialect from 'migratrom'
Named export, not default.
postgresAdapter
import { postgresAdapter } from 'migratrom/adapters/postgres'
import { postgresAdapter } from 'migratrom'
Adapter subpath import; not re-exported from main entry.
libsqlAdapter
import { libsqlAdapter } from 'migratrom/adapters/sqlite'
import { libsqlAdapter } from 'migratrom'
Adapter subpath import; not re-exported from main entry.
Migration
import type { Migration } from 'migratrom'
import { Migration } from 'migratrom'
Migration is a type, use import type with TypeScript.
createTable
import { createTable } from 'migratrom'
import { CreateTable } from 'migratrom'
Namespace-style import (lower camelCase) for operation functions.

Shows a two-step migration: create user table with SERIAL id and email, then add password_hash column.

import { applyMigrations, createTable, addColumn, PostgresDialect } from "migratrom"; import { postgresAdapter } from "migratrom/adapters/postgres"; import type { Migration } from "migratrom"; import postgres from "postgres"; const dialect = new PostgresDialect(); const sql = postgres(process.env.DATABASE_URL ?? ""); const M1: Migration = { id: 1, parentId: null, operations: [ createTable("public", "user", [ { name: "id", typeSql: "SERIAL" }, { name: "email", typeSql: "text" }, ], dialect, { columns: ["id"] }), ], }; const M2: Migration = { id: 2, parentId: 1, operations: [ addColumn("public", "user", { name: "password_hash", typeSql: "text" }, dialect), ], }; await applyMigrations([M1, M2], { db: postgresAdapter(sql), dialect }); console.log("Migrations applied");
Debug
Known issues
gotchaAdapter import path uses subpath exports (e.g., migratrom/adapters/postgres). Not available from main entry.
fix
Use full subpath import: import { postgresAdapter } from 'migratrom/adapters/postgres'
affects: >=0.0.0
gotchaOperation functions require a dialect instance as last argument. Forgetting it results in runtime error.
fix
Always pass dialect: createTable('public', 't', cols, dialect, opts)
affects: >=0.0.0
breakingParent migration must have parentId: null. If you set parentId to undefined, verification may fail.
fix
Set parentId to null for root migrations.
affects: >=0.0.0
gotchaESM-only package. Cannot use require() in Node without ESM wrapper.
fix
Use import syntax or configure Node with type: 'module' in package.json.
affects: >=0.0.0
deprecatedNo known deprecations yet. Version 0.0.4 is early stage.
Errors
Common errors & fixes
ERR_PACKAGE_PATH_NOT_EXPORTED: Package subpath './adapters/postgres' is not defined by "exports" in package.json
Using older version (<0.0.4) that did not export adapter subpaths, or typo in path.
fix
Update migratrom to 0.0.4 or later. Use exact import path: 'migratrom/adapters/postgres'.
TypeError: Cannot read properties of undefined (reading 'toSQL')
Missing dialect argument in operation call, e.g., createTable(...) without dialect.
fix
Ensure every operation receives a dialect instance as its last argument.
Error: Migration parentId missing or null chain broken
Migration tree has gaps (parentId points to non-existent id) or cycles.
fix
Verify all parentId values refer to existing migration ids. Root migrations must have parentId: null.
SyntaxError: Cannot use import statement outside a module
Trying to import ESM-only package in a CommonJS module without proper configuration.
fix
Set type: 'module' in package.json or rename file to .mjs.
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies
postgresoptionalPostgreSQL driver when using PostgresDialect
libsqloptionalSQLite driver when using SQLiteDialect
Agent activity
8 hits · last 30 days
node
6
Resources
migratrom — npm install migratrom · libregistry