{"id":43050,"library":"migratio","title":"migratio","description":"migratio is a lightweight, automated migration tool for PostgreSQL with support for both SQL and JavaScript migration files. The current stable version is 2.0.3, released with an engine requirement of Node.js >=4. It runs migrations in transactions with table-level locking to ensure atomic batch execution. Key differentiators include support for async/await and generators out of the box, configurable defaults via package.json, and a non-verbose API with current, up, and down commands. The package is published on npm and distributed as CommonJS.","status":"active","version":"2.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/floatdrop/migratio","tags":["javascript","postgres","migration","migratio","cli"],"install":[{"cmd":"npm install migratio","lang":"bash","label":"npm"},{"cmd":"yarn add migratio","lang":"bash","label":"yarn"},{"cmd":"pnpm add migratio","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"PostgreSQL database connectivity","package":"pg-promise","optional":false},{"reason":"Wraps generator functions in migration files","package":"co","optional":true}],"imports":[{"note":"migratio is a CommonJS module; it does not have a named or default ES module export.","wrong":"import migratio from 'migratio';","symbol":"default","correct":"const migratio = require('migratio');"},{"note":"up, down, and current are methods on the default export object.","wrong":"","symbol":"up","correct":"const { up } = require('migratio');"},{"note":"ESM import does not work; use destructuring from CommonJS require.","wrong":"import { down } from 'migratio';","symbol":"down","correct":"const { down } = require('migratio');"},{"note":"","wrong":"","symbol":"current","correct":"const { current } = require('migratio');"}],"quickstart":{"code":"const migratio = require('migratio');\n\nconst connection = process.env.DATABASE_URL ?? 'postgres://localhost/db';\n\n// Show current batch\nmigratio.current({ connection, verbose: true })\n  .then(() => console.log('Done'))\n  .catch(err => console.error(err));\n\n// Apply all pending migrations\nmigratio.up({ connection, verbose: true })\n  .then(() => console.log('Migration applied'))\n  .catch(err => console.error(err));\n\n// Rollback latest batch\nmigratio.down({ connection, verbose: true })\n  .then(() => console.log('Migration rolled back'))\n  .catch(err => console.error(err));","lang":"javascript","description":"Demonstrates how to require migratio, connect to Postgres, and run current/up/down commands with verbose output."},"warnings":[{"fix":"Ensure all migration files start with digits followed by a hyphen.","message":"Migration files must be named with a leading numeric revision (e.g., 000001-init.sql). Files with non-numeric prefixes are ignored.","severity":"gotcha","affected_versions":"*"},{"fix":"Use the 'unsafe' option to disable locking, but be aware of potential concurrency issues.","message":"Migrations run in a transaction with a lock on the migrations table. If any migration fails, the entire batch is rolled back.","severity":"gotcha","affected_versions":"*"},{"fix":"Set the DATABASE_URL environment variable or pass 'connection' explicitly.","message":"The default database connection uses process.env.DATABASE_URL. Fallback to hardcoded string is not recommended.","severity":"deprecated","affected_versions":"*"},{"fix":"Upgrade Node to version 4 or later.","message":"Node.js >=4 is required. No support for older Node versions.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'2.0.3':25 '4':33 'api':70 'async/await':54 'atom':46 'autom':6 'batch':47 'box':60 'cli':91 'command':76 'commonj':86 'configur':61 'current':21,72 'default':62 'differenti':50 'distribut':84 'engin':29 'ensur':45 'execut':48 'file':19 'generat':56 'includ':51 'javascript':17,87 'key':49 'level':42 'lightweight':5 'lock':43 'migrat':7,18,36,89 'migratio':1,2,90 'node.js':32 'non':68 'non-verbos':67 'npm':82 'packag':78 'package.json':64 'postgr':88 'postgresql':10 'publish':80 'releas':26 'requir':30 'run':35 'sql':15 'stabl':22 'support':12,52 'tabl':41 'table-level':40 'tool':8 'transact':38 'verbos':69 'version':23 'via':63","created_at":"2026-06-05T16:57:56.352991+00:00","updated_at":"2026-06-05T16:57:56.352991+00:00","problems":[{"fix":"Use const migratio = require('migratio'); instead of import.","cause":"Using ESM import syntax (import) with a CommonJS module.","error":"TypeError: migratio.up is not a function"},{"fix":"Run 'npm install --save migratio' in your project directory.","cause":"migratio not installed or not in node_modules.","error":"Error: Cannot find module 'migratio'"},{"fix":"Ensure connection string is correct for your Postgres instance, e.g., 'postgres://user:password@localhost:5432/db'.","cause":"Connection string uses wrong credentials. (Note: migratio is for Postgres, not MySQL, but similar error may occur).","error":"Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)"},{"fix":"Install co: npm install --save co, or convert generator functions to async/await.","cause":"co is required only if you use generator functions in JS migrations.","error":"Error: Cannot find module 'co'"}],"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":"https://github.com/floatdrop/migratio#readme","github":"https://github.com/floatdrop/migratio","docs":null,"changelog":null,"pypi":null,"npm":"migratio","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-05","next_check":"2026-09-03","install_tag":null}}