Registry / database / ship-hold-migration

ship-hold-migration

JSON →
library2.0.0jsnpmunverified

Migration adapter for ship-hold, a PostgreSQL ORM. Version 2.0.0. Provides up/down/pending/executed migration commands. Migrations are files with up/down async functions and timestamp. Options: modelName, tableName, directory. ESM and CJS compatible.

npm install ship-hold-migration
INSTALL
IMPORT
SIG · SHIP-HOLD-MIGRATIO
S
ship-hold-migration
databasejavascriptv2.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.

mig
import mig from 'ship-hold-migration'
const mig = require('ship-hold-migration')
Default export is a function that takes a ship-hold instance.
ship-hold
import sh from 'ship-hold'
const sh = require('ship-hold')(options)
ship-hold is required as a dependency.
migrator
const migrator = sh.migrator()
const migrator = require('ship-hold-migration').migrator()
After calling mig(sh), sh.migrator() becomes available.

Initialize ship-hold, attach migration adapter, run all pending migrations, then rollback the last one.

import sh from 'ship-hold'; import mig from 'ship-hold-migration'; const db = sh({ host: 'localhost', port: 5432, database: 'test', user: 'postgres', password: process.env.DB_PASSWORD ?? '' }); mig(db); const migrator = db.migrator(); async function runMigrations() { const pending = await migrator.pending(); console.log('Pending migrations:', pending); const result = await migrator.up(); console.log('Executed migrations:', result); await migrator.down(); console.log('Rolled back last migration'); } runMigrations().catch(console.error);
Debug
Known issues
gotchaMigrations require a 'timestamp' property for ordering. Without it, order may be undefined.
fix
Ensure each migration file exports a numeric timestamp property.
affects: >=0.0.0
gotchaDefault directory is '/migrations' relative to project root. Custom directory via options.
fix
Use { directory: './custom-migrations' } in mig(db, options).
affects: >=0.0.0
gotchaThe 'up' and 'down' functions receive the ship-hold instance as first argument, not a query builder.
fix
Use sh.query() inside migration functions.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'ship-hold-migration'
ship-hold-migration not installed or not in node_modules.
fix
npm install ship-hold-migration
TypeError: mig(...) is not a function
Importing the module incorrectly, e.g., using default import where named export expected.
fix
Use import mig from 'ship-hold-migration' or const mig = require('ship-hold-migration').
sh.migrator is not a function
The mig function was not called on the ship-hold instance.
fix
Ensure you call mig(sh) before accessing sh.migrator().
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
ship-holdrequiredCore ORM that this adapter extends
Agent activity
13 hits · last 30 days
node
10
Meta
2
Resources
ship-hold-migration — npm install ship-hold-migration · libregistry