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.fixUse 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.fixAlways 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.fixSet parentId to null for root migrations.
affects: >=0.0.0
gotchaESM-only package. Cannot use require() in Node without ESM wrapper.fixUse 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.
fixUpdate 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.
fixEnsure 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.
fixVerify 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.
fixSet type: 'module' in package.json or rename file to .mjs.
Audit
Dependencies
postgresoptionalPostgreSQL driver when using PostgresDialect
libsqloptionalSQLite driver when using SQLiteDialect