{"id":48525,"library":"migrationjs","title":"MigrationJS","description":"A Node.js database migration system that allows creating and running migrations with up/down functions. Currently at version 0.4.12, it provides a CLI for generating migration files, migrating, and rolling back. Key differentiators include a schema builder with Blueprint for table operations (create, alter, drop), TypeScript support, and a simple batch-based migration tracking system. It supports MySQL, PostgreSQL, and SQLite. The package is minimal and lightweight but lacks features like seeding or advanced error handling.","status":"active","version":"0.4.12","language":"javascript","source_language":"en","source_url":"https://github.com/msvdaamen/migrationjs","tags":["javascript","typescript"],"install":[{"cmd":"npm install migrationjs","lang":"bash","label":"npm"},{"cmd":"yarn add migrationjs","lang":"bash","label":"yarn"},{"cmd":"pnpm add migrationjs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"for MySQL database connections","package":"mysql2","optional":true},{"reason":"for PostgreSQL database connections","package":"pg","optional":true},{"reason":"for SQLite database connections","package":"better-sqlite3","optional":true}],"imports":[{"note":"ESM-style import; CommonJS require is possible but not recommended.","wrong":"const Migration = require('migrationjs').Migration","symbol":"Migration","correct":"import { Migration } from 'migrationjs'"},{"note":"Named export, not default.","wrong":"import Blueprint from 'migrationjs'","symbol":"Blueprint","correct":"import { Blueprint } from 'migrationjs'"},{"note":"ESM import preferred. Schema is a class with static methods.","wrong":"const Schema = require('migrationjs').Schema","symbol":"Schema","correct":"import { Schema } from 'migrationjs'"}],"quickstart":{"code":"import { Migration, Blueprint, Schema } from 'migrationjs';\nimport { config } from 'dotenv';\nconfig();\n\n// Create a migration class (usually in a separate file)\nexport default class CreateUsersTable extends Migration {\n    async up() {\n        await Schema.create('users', (table: Blueprint) => {\n            table.id();\n            table.string('name');\n            table.timestamps();\n        });\n    }\n\n    async down() {\n        await Schema.dropIfExists('users');\n    }\n}\n\n// In your main file, run migrations using CLI:\n// migrationjs migrate\n// Or programmatically (not documented but possible via internals, avoid)","lang":"typescript","description":"Shows how to define a migration class with up/down methods using Schema and Blueprint to create a 'users' table."},"warnings":[{"fix":"Create a 'migrations' folder in your project root, or configure the path in migrationjs.conf.json.","message":"Migration files must be placed in a 'migrations' directory by default; otherwise CLI will not find them.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always implement a matching 'down' that drops/alters what 'up' created.","message":"The 'down' method must exactly reverse the 'up' method; there is no validation and orphaned data may occur.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Change imports: import { Migration } from 'migrationjs' instead of import Migration from 'migrationjs'.","message":"Version 0.4.x changed the import style from default to named exports.","severity":"breaking","affected_versions":">=0.4.0 <0.5.0"},{"fix":"Replace Schema.drop with Schema.dropIfExists to avoid errors when table doesn't exist.","message":"The 'Schema.drop' method is deprecated; use 'Schema.dropIfExists' instead.","severity":"deprecated","affected_versions":">=0.4.0"}],"env_vars":null,"search_vec":"'0.4.12':19 'advanc':75 'allow':8 'alter':44 'back':31 'base':53 'batch':52 'batch-bas':51 'blueprint':39 'builder':37 'cli':23 'creat':9,43 'current':16 'databas':4 'differenti':33 'drop':45 'error':76 'featur':71 'file':27 'function':15 'generat':25 'handl':77 'includ':34 'javascript':78 'key':32 'lack':70 'lightweight':68 'like':72 'migrat':5,12,26,28,54 'migrationj':1 'minim':66 'mysql':59 'node.js':3 'oper':42 'packag':64 'postgresql':60 'provid':21 'roll':30 'run':11 'schema':36 'seed':73 'simpl':50 'sqlite':62 'support':47,58 'system':6,56 'tabl':41 'track':55 'typescript':46,79 'up/down':14 'version':18","created_at":"2026-06-07T16:57:06.471714+00:00","updated_at":"2026-06-07T16:57:06.471714+00:00","problems":[{"fix":"Install migrationjs locally: npm install migrationjs --save-dev, then use npx migrationjs migrate.","cause":"Package not installed or not globally installed when using CLI.","error":"Error: Cannot find module 'migrationjs'"},{"fix":"Use import { Schema } from 'migrationjs'.","cause":"Incorrect import: using default import instead of named import.","error":"TypeError: Schema.create is not a function"},{"fix":"Export default a class that extends the Migration class.","cause":"Exporting an object or function instead of a class.","error":"Migration file must export a class extending Migration"}],"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/msvdaamen/migrationjs#readme","github":"https://github.com/msvdaamen/migrationjs","docs":null,"changelog":null,"pypi":null,"npm":"migrationjs","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}}