{"id":49346,"library":"ship-hold-migration","title":"ship-hold-migration","description":"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.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","ship-hold","database","sql","migration","postgresql"],"install":[{"cmd":"npm install ship-hold-migration","lang":"bash","label":"npm"},{"cmd":"yarn add ship-hold-migration","lang":"bash","label":"yarn"},{"cmd":"pnpm add ship-hold-migration","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core ORM that this adapter extends","package":"ship-hold","optional":false}],"imports":[{"note":"Default export is a function that takes a ship-hold instance.","wrong":"const mig = require('ship-hold-migration')","symbol":"mig","correct":"import mig from 'ship-hold-migration'"},{"note":"ship-hold is required as a dependency.","wrong":"const sh = require('ship-hold')(options)","symbol":"ship-hold","correct":"import sh from 'ship-hold'"},{"note":"After calling mig(sh), sh.migrator() becomes available.","wrong":"const migrator = require('ship-hold-migration').migrator()","symbol":"migrator","correct":"const migrator = sh.migrator()"}],"quickstart":{"code":"import sh from 'ship-hold';\nimport mig from 'ship-hold-migration';\n\nconst db = sh({\n  host: 'localhost',\n  port: 5432,\n  database: 'test',\n  user: 'postgres',\n  password: process.env.DB_PASSWORD ?? ''\n});\n\nmig(db);\n\nconst migrator = db.migrator();\n\nasync function runMigrations() {\n  const pending = await migrator.pending();\n  console.log('Pending migrations:', pending);\n  const result = await migrator.up();\n  console.log('Executed migrations:', result);\n  await migrator.down();\n  console.log('Rolled back last migration');\n}\n\nrunMigrations().catch(console.error);","lang":"javascript","description":"Initialize ship-hold, attach migration adapter, run all pending migrations, then rollback the last one."},"warnings":[{"fix":"Ensure each migration file exports a numeric timestamp property.","message":"Migrations require a 'timestamp' property for ordering. Without it, order may be undefined.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use { directory: './custom-migrations' } in mig(db, options).","message":"Default directory is '/migrations' relative to project root. Custom directory via options.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use sh.query() inside migration functions.","message":"The 'up' and 'down' functions receive the ship-hold instance as first argument, not a query builder.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'2.0.0':15 'adapt':6 'async':25 'cjs':35 'command':19 'compat':36 'databas':41 'directori':32 'esm':33 'file':22 'function':26 'hold':3,10,40 'javascript':37 'migrat':4,5,18,20,43 'modelnam':30 'option':29 'orm':13 'postgresql':12,44 'provid':16 'ship':2,9,39 'ship-hold':8,38 'ship-hold-migr':1 'sql':42 'tablenam':31 'timestamp':28 'up/down':24 'up/down/pending/executed':17 'version':14","created_at":"2026-06-07T17:01:17.412626+00:00","updated_at":"2026-06-07T17:01:17.412626+00:00","problems":[{"fix":"npm install ship-hold-migration","cause":"ship-hold-migration not installed or not in node_modules.","error":"Cannot find module 'ship-hold-migration'"},{"fix":"Use import mig from 'ship-hold-migration' or const mig = require('ship-hold-migration').","cause":"Importing the module incorrectly, e.g., using default import where named export expected.","error":"TypeError: mig(...) is not a function"},{"fix":"Ensure you call mig(sh) before accessing sh.migrator().","cause":"The mig function was not called on the ship-hold instance.","error":"sh.migrator is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"ship-hold-migration","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}