{"library":"marv","title":"Marv","description":"Marv is a programmatic database migration tool designed for Node.js environments, offering a flexible, driver-based approach to managing schema changes. Currently stable at version 6.1.0, it supports a wide range of relational databases including MySQL, PostgreSQL, SQLite, Microsoft SQL Server, and Oracle DB through dedicated pluggable drivers (e.g., `marv-pg-driver`). It distinguishes itself by providing both Promise and Callback-based APIs for integration into various application architectures. Marv's core functionality involves scanning a directory for SQL migration files, validating their sequence, and applying them to the target database. It enforces strict ordering, reporting errors for duplicate levels or out-of-sequence execution, which necessitates careful branching strategies when developing new migrations. Releases appear to follow a semantic versioning approach, with major versions introducing significant changes.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install marv"],"cli":{"name":"marv","version":null}},"imports":["const marv = require('marv/api/promise');","const marv = require('marv/api/callback');","const pgDriver = require('marv-pg-driver');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const path = require('path');\nconst marv = require('marv/api/promise');\nconst pgDriver = require('marv-pg-driver');\n\nconst migrationsDirectory = path.resolve(__dirname, 'migrations');\n\n// Create a dummy migrations directory and file for demonstration\nconst fs = require('fs');\nif (!fs.existsSync(migrationsDirectory)) {\n  fs.mkdirSync(migrationsDirectory);\n}\nconst migrationFile = path.join(migrationsDirectory, '001.create-test-table.sql');\nif (!fs.existsSync(migrationFile)) {\n  fs.writeFileSync(migrationFile, 'CREATE TABLE IF NOT EXISTS test_table (id SERIAL PRIMARY KEY, name VARCHAR(255));');\n}\n\nasync function runMigrations() {\n  try {\n    // Placeholder for actual PostgreSQL connection details\n    const connection = {\n      host: process.env.DB_HOST ?? 'localhost',\n      port: parseInt(process.env.DB_PORT ?? '5432', 10),\n      user: process.env.DB_USER ?? 'postgres',\n      password: process.env.DB_PASSWORD ?? 'password',\n      database: process.env.DB_NAME ?? 'mydatabase',\n      // Optional: ssl: { rejectUnauthorized: false } for local testing if needed\n    };\n\n    const migrations = await marv.scan(migrationsDirectory);\n    await marv.migrate(migrations, pgDriver({ connection }));\n    console.log('Migrations applied successfully!');\n  } catch (err) {\n    console.error('Migration failed:', err.message);\n    process.exit(1);\n  }\n}\n\nrunMigrations();\n","lang":"javascript","description":"This quickstart demonstrates how to use Marv with its Promise API and a PostgreSQL driver to scan for and apply migrations from a local directory. It includes boilerplate for database connection configuration and creates a sample migration file if none exists for immediate execution.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}