Registry / database / schemalens-engine

schemalens-engine

JSON →
library1.0.0jsnpmunverified

SchemaLens core diff engine for semantic SQL schema diffing, breaking change detection, and migration generation. Version 1.0.0, actively maintained with monthly releases. Supports PostgreSQL, MySQL/MariaDB, SQLite, SQL Server, and Oracle. Key differentiators: zero dependencies, built-in rename detection, risk scoring, and safe migration mode. Unlike generic diff tools, it understands SQL semantics and detects breaking changes automatically.

npm install schemalens-engine
INSTALL
IMPORT
SIG · SCHEMALENS-ENGINE
S
schemalens-engine
databasejavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

diffSchemas
const { diffSchemas } = require('schemalens-engine');
const diffSchemas = require('schemalens-engine').diffSchemas;
CommonJS destructuring is preferred; direct property access also works.
generateMigration
const { generateMigration } = require('schemalens-engine');
import generateMigration from 'schemalens-engine';
This package does not provide default exports; only named exports via CommonJS.
detectBreakingChanges
const { detectBreakingChanges } = require('schemalens-engine');
const detectBreakingChanges = require('schemalens-engine');
detectBreakingChanges is a named export, not the default export.
calculateRiskScore
const { calculateRiskScore } = require('schemalens-engine');
const calculateRiskScore = require('schemalens-engine').calculateRiskScore;
Both patterns work but destructuring is idiomatic.

Compares two SQL schemas, generates a migration script, detects breaking changes, and calculates risk score.

const { diffSchemas, generateMigration, detectBreakingChanges, calculateRiskScore } = require('schemalens-engine'); const oldSQL = `CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(100));`; const newSQL = `CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(255), email VARCHAR(255));`; const result = diffSchemas(oldSQL, newSQL, { dialect: 'postgres' }); console.log('Added tables:', result.addedTables.length); console.log('Removed tables:', result.removedTables.length); console.log('Modified tables:', result.modifiedTables.length); const migration = generateMigration(result, { dialect: 'postgres' }); console.log(migration); const breaking = detectBreakingChanges(result); console.log('Breaking changes:', breaking.length); const risk = calculateRiskScore(result); console.log('Risk score:', risk.score, risk.label);
Debug
Known issues
breakingrenameThreshold default changed from 0.5 to 0.6 in v1.0.0
fix
Update code to explicitly pass renameThreshold if default is relied upon.
affects: <1.0.0
gotchaSQLite does not support functions or triggers; parsing such statements will be ignored.
fix
Ensure SQLite schemas do not contain function/trigger definitions.
affects: >=0.0.0
gotchaOracle dialect requires specifying schema prefix for object names; otherwise detection may be incomplete.
fix
Use fully qualified names (e.g., SCHEMA.TABLE) in SQL strings for Oracle.
affects: >=0.0.0
breakingOutput format of detectBreakingChanges changed in v0.9.0; 'table' field no longer includes schema prefix.
fix
Update code expecting schema prefix to handle plain table names.
affects: <0.9.0
Errors
Common errors & fixes
TypeError: diffSchemas is not a function
Incorrect import using default import or missing destructuring.
fix
Use const { diffSchemas } = require('schemalens-engine');
Error: Unsupported dialect: 'sql server'
Dialect string must match exactly: 'mssql' for SQL Server.
fix
Use dialect: 'mssql' instead of 'sql server'.
SyntaxError: Unexpected token 'export'
Using ES module import (import) in a CommonJS project.
fix
Use require() or set type: 'module' in package.json and use import with correct named import.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
16
Meta
2
Resources
schemalens-engine — npm install schemalens-engine · libregistry