{"library":"migrate-semver","title":"migrate-semver","description":"migrate-semver is a database-agnostic Node.js library that manages migrations based on SemVer version strings rather than sequential numbers or timestamps. Version 0.7.0 is the latest stable release, with infrequent updates. It provides a SemVerMigration class that scans a migrations directory for versioned folders and runs only the migrations needed to reach a target version. Unlike timestamp-based tools, it allows arbitrary version jumps and skips already applied versions. It requires a plugin for database-specific storage, with a Mongoose plugin available. The library handles connections, migration tracking, and custom options passed to migrations.","language":"javascript","status":"active","last_verified":"Fri May 01","install":{"commands":["npm install migrate-semver"],"cli":null},"imports":["import { SemVerMigration } from 'migrate-semver'","const migrateSemver = require('migrate-semver')","import type { SemVerMigration } from 'migrate-semver'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { SemVerMigration } from 'migrate-semver';\nimport path from 'path';\nimport { plugin } from './my-plugin'; // your database plugin\n\nconst migrate = new SemVerMigration({\n  migrationsDirectory: path.join(process.cwd(), 'migrations')\n}, plugin());\n\nmigrate.connect({}, (err) => {\n  if (err) {\n    console.error('Connection failed', err);\n    process.exit(1);\n  }\n\n  const targetVersion = '0.3.0';\n\n  migrate.canMigrate({ version: targetVersion }, (err, canMigrate) => {\n    if (err || !canMigrate) {\n      console.error('Cannot migrate', err);\n      process.exit(1);\n    }\n\n    migrate.up({ version: targetVersion }, (err) => {\n      if (err) {\n        console.error('Migration failed', err);\n        process.exit(1);\n      }\n      console.log(`Successfully migrated to ${targetVersion}`);\n      migrate.disconnect();\n    });\n  });\n});","lang":"typescript","description":"Shows how to instantiate SemVerMigration with a plugin, connect, check migration feasibility, and run an up migration to a specific SemVer version.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}