Registry / database / migration-tools

migration-tools

JSON →
library1.0.0jsnpmunverified

A lightweight database migration tool for regenerating database schemas. Version 1.0.0 is the initial stable release. Designed for simplicity, it focuses on executing up/down migrations via configuration files. Key differentiators include zero dependencies and a flat learning curve compared to tools like Knex or TypeORM. Release cadence is ad-hoc.

npm install migration-tools
INSTALL
IMPORT
SIG · MIGRATION-TOOLS
M
migration-tools
databasejavascriptv1.0.0
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.

migrate
import { migrate } from 'migration-tools'
const migrate = require('migration-tools')
ESM-only since v1.0.0
MigrationConfig
import type { MigrationConfig } from 'migration-tools'
import { MigrationConfig } from 'migration-tools'
TypeScript interface when using type-only import
runMigrations
import { runMigrations } from 'migration-tools'
const { runMigrations } = require('migration-tools')
CommonJS require is not supported

Shows how to import and use the migrate function with a database connection string and migrations directory.

import { migrate } from 'migration-tools'; const config = { connection: process.env.DB_URL ?? 'postgres://user:pass@localhost:5432/mydb', migrationsDir: './migrations', }; await migrate.up(config); console.log('Migrations applied.');
Debug
Known issues
breakingBreaking: The API uses ESM only. CommonJS require() will fail with ERR_REQUIRE_ESM.
fix
Use import syntax and ensure your project is set to ES modules.
affects: >=1.0.0
gotchaThe library does not create the database; it assumes the database already exists. Attempting migration without a pre-existing database will throw a connection error.
fix
Create the database manually before running migrations.
affects: >=1.0.0
deprecatedThe config field 'schemaTable' is deprecated in favor of 'migrationsTable'.
fix
Rename 'schemaTable' to 'migrationsTable' in your config.
affects: >=1.0.0
gotchaAll migration files must have .sql extension; .js/.ts files are not supported.
fix
Use .sql files for migration scripts.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: migration_tools_1.migrate.up is not a function
CommonJS require is used instead of ESM import.
fix
Use import { migrate } from 'migration-tools' and set type: module in package.json.
Error: Cannot find module './migrations'
The migrations directory path is relative; the library does not resolve it to the current working directory.
fix
Use an absolute path or path.resolve(__dirname, './migrations').
Error: relation "migrations" does not exist
The library's default migrations tracking table is missing.
fix
Ensure the migrationsTable is correctly configured or run the initial table creation first (e.g., with a SQL script).
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources
migration-tools — npm install migration-tools · libregistry