npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

schemalens-engine

v1.0.0

Published

SchemaLens core diff engine — semantic SQL schema diff, breaking change detection, and migration generation

Readme

schemalens-engine

SchemaLens core diff engine — semantic SQL schema diff, breaking change detection, and migration generation. Zero dependencies. MIT licensed.

Install

npm install schemalens-engine

Quick Start

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);

API

diffSchemas(oldSQL, newSQL, options)

Compare two SQL schema dumps and return a structured diff.

Options:

  • dialect'postgres' | 'mysql' | 'sqlite' | 'mssql' | 'oracle' | 'generic'
  • renameThreshold — Number 0–1 for rename detection sensitivity (default: 0.6)

Returns:

{
  addedTables: [...],
  removedTables: [...],
  modifiedTables: [...],
  addedIndexes: [...],
  removedIndexes: [...],
  addedViews: [...],
  removedViews: [...],
  modifiedViews: [...],
  addedFunctions: [...],
  removedFunctions: [...],
  // ...
}

generateMigration(diffResult, options)

Generate a dialect-specific migration script from a diff result.

Options:

  • dialect — same as above
  • safeMode — if true, wraps dangerous changes in transactions/conditionals where supported

detectBreakingChanges(diffResult)

Returns an array of breaking change objects with type, table, column, and message.

calculateRiskScore(diffResult)

Returns { score: number, label: 'Low' | 'Medium' | 'High' }.

Supported Dialects

| Dialect | Tables | Columns | Indexes | Constraints | Views | Functions | Triggers | |---------|--------|---------|---------|-------------|-------|-----------|----------| | PostgreSQL | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | MySQL / MariaDB | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | SQLite | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | | SQL Server / Azure SQL | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | Oracle | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |

Testing

Run the full test suite:

npm test

License

MIT — see LICENSE for details.