This guide helps you migrate between versions of Migrilla.
Required Action: Update your code to use factory functions instead of classes.
const Migrilla = require('migrilla');
const migrilla = new Migrilla({
host: 'localhost',
database: 'myapp',
user: 'postgres',
password: 'secret'
});const createMigrilla = require('migrilla');
const migrilla = createMigrilla({
host: 'localhost',
database: 'myapp',
user: 'postgres',
password: 'secret'
});- Constructor:
new Migrilla(config)is nowcreateMigrilla(config) - CLI Internal:
new MigrillaCLI()is nowcreateMigrillaCLI()(only affects internal code)
- Functional Design: More predictable and testable code
- Closure-based State: Immutable configuration and cleaner memory management
- Better Performance: Reduced object instantiation overhead
- Update Imports: Change variable name from
MigrillatocreateMigrilla - Update Usage: Replace
new Migrilla()withcreateMigrilla() - Test: Functionality remains identical, just different instantiation
// Before
const Migrilla = require('migrilla');
const migrilla = new Migrilla(config);
// After
const createMigrilla = require('migrilla');
const migrilla = createMigrilla(config);
// All methods work exactly the same
await migrilla.up();
await migrilla.down();
await migrilla.status();
await migrilla.close();Required Action: Update your environment variables to include the MIGRILLA_ prefix.
DB_HOST=localhost
DB_PORT=5432
DB_NAME=myapp
DB_USER=postgres
DB_PASSWORD=secret
DATABASE_URL=postgres://user:pass@host:port/db
DB_SSL=trueMIGRILLA_DB_HOST=localhost
MIGRILLA_DB_PORT=5432
MIGRILLA_DB_NAME=myapp
MIGRILLA_DB_USER=postgres
MIGRILLA_DB_PASSWORD=secret
MIGRILLA_DATABASE_URL=postgres://user:pass@host:port/db
MIGRILLA_DB_SSL=trueNo Action Required: If you're importing Migrilla programmatically, the import path remains the same:
const Migrilla = require('migrilla'); // Still worksThe main entry point in package.json has been updated to point to lib/index.js, but this is transparent to users.
- Environment Variables: All environment variables now require the
MIGRILLA_prefix - High-level Transaction API: Removed to simplify the API surface (only callback-style transactions remain)
- Namespace Isolation: Environment variables won't conflict with other tools
- Cleaner API: Single transaction approach reduces complexity
- Better Organization: Core files moved to
lib/directory
- Update Environment Variables: Add
MIGRILLA_prefix to all your environment variables - Update
.envfiles: Rename all database-related variables - Update CI/CD: Update deployment scripts with new variable names
- Test: Run
migrilla statusto verify connection still works
#!/bin/bash
# migrate-env.sh - Helper script to update environment variables
# Rename variables in .env file
if [ -f ".env" ]; then
sed -i.backup \
-e 's/^DB_HOST=/MIGRILLA_DB_HOST=/' \
-e 's/^DB_PORT=/MIGRILLA_DB_PORT=/' \
-e 's/^DB_NAME=/MIGRILLA_DB_NAME=/' \
-e 's/^DB_USER=/MIGRILLA_DB_USER=/' \
-e 's/^DB_PASSWORD=/MIGRILLA_DB_PASSWORD=/' \
-e 's/^DATABASE_URL=/MIGRILLA_DATABASE_URL=/' \
-e 's/^DB_SSL=/MIGRILLA_DB_SSL=/' \
.env
echo "✅ Environment variables updated in .env"
fiIf you encounter issues during migration:
- Check the CHANGELOG.md for detailed changes
- Review the README.md for updated examples
- Run
migrilla helpto see current CLI options - Verify your environment variables with
env | grep MIGRILLA
If you need to rollback to v1.0.0:
npm install migrilla@1.0.0Then revert your environment variable names back to the old format without the MIGRILLA_ prefix.