Meadow Migration Manager
raw JSON → 0.0.13 verified Sat Apr 25 auth: no javascript
Meadow Migration Manager is a CLI, Web, and Terminal UI tool for managing database schema migrations within the Meadow ecosystem. As of version 0.0.13, it supports MySQL, PostgreSQL, MSSQL, and SQLite through pluggable providers. It provides a complete pipeline from MicroDDL schema definition via Stricture compilation, diffing between schema versions, SQL migration generation for target dialects, and live database deployment. Key differentiators include a multi-interface approach (CLI with 11 commands, blessed-based TUI, and interactive flow diagrams) and deep integration with Meadow data access libraries.
Common errors
error TypeError: MeadowMigrationManager is not a constructor ↓
cause Using ES module import syntax which is not supported; the package only exports a CommonJS module.
fix
Use
const MeadowMigrationManager = require('meadow-migrationmanager'); instead of import. error Cannot find module 'stricture' ↓
cause Missing peer dependency stricture which is required for DDL compilation.
fix
Install the missing dependency:
npm install stricture. Warnings
breaking Service providers are accessed via `instantiateServiceProvider` method, not as named exports from the package. ↓
fix Always create a MeadowMigrationManager instance first and use its method to obtain service instances.
gotcha The package does not provide TypeScript type definitions; all APIs are dynamically typed. ↓
fix Use JavaScript or manually create TypeScript declaration files if type safety is required.
gotcha Database connections and schema library data are stored in-memory and not persisted unless explicitly configured with a storage provider. ↓
fix Configure a persistent storage backend via the configuration object when instantiating MeadowMigrationManager.
Install
npm install meadow-migrationmanager yarn add meadow-migrationmanager pnpm add meadow-migrationmanager Imports
- MeadowMigrationManager wrong
import MeadowMigrationManager from 'meadow-migrationmanager';correctconst MeadowMigrationManager = require('meadow-migrationmanager'); - SchemaLibrary wrong
const { SchemaLibrary } = require('meadow-migrationmanager');correctconst tmpManager = new MeadowMigrationManager({}); const schemaLib = tmpManager.instantiateServiceProvider('SchemaLibrary'); - StrictureAdapter wrong
const { StrictureAdapter } = require('meadow-migrationmanager');correctconst tmpManager = new MeadowMigrationManager({}); const stricture = tmpManager.instantiateServiceProvider('StrictureAdapter'); - ConnectionLibrary
const tmpManager = new MeadowMigrationManager({}); const connLib = tmpManager.instantiateServiceProvider('ConnectionLibrary');
Quickstart
const MeadowMigrationManager = require('meadow-migrationmanager');
// Instantiate the manager with optional configuration
const tmpManager = new MeadowMigrationManager({});
// Access the schema library service
const schemaLib = tmpManager.instantiateServiceProvider('SchemaLibrary');
// Add a MicroDDL schema from a string
schemaLib.addSchema('bookstore', '!Book\n@IDBook\n$Title 200\n$Genre 128\n');
// Compile the DDL via Stricture
const stricture = tmpManager.instantiateServiceProvider('StrictureAdapter');
stricture.compileDDL(schemaLib.getSchema('bookstore').DDL, (pError, pSchema) => {
if (pError) {
console.error('Compilation error:', pError);
return;
}
console.log('Compiled tables:', Object.keys(pSchema.Tables));
});
// Add a second version and diff
schemaLib.addSchema('bookstore-v2', '!Book\n@IDBook\n$Title 256\n$Genre 64\n$Price 10,2\n');
stricture.compileDDL(schemaLib.getSchema('bookstore-v2').DDL, (err2, schema2) => {
if (!err2) {
const diff = tmpManager.instantiateServiceProvider('DiffEngine');
diff.diffSchema(schemaLib.getSchema('bookstore'), schemaLib.getSchema('bookstore-v2'), (dErr, dResult) => {
console.log('Added tables:', dResult.Added);
console.log('Removed tables:', dResult.Removed);
console.log('Modified tables:', dResult.Modified);
});
}
});