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 🙏

© 2024 – Pkg Stats / Ryan Hefner

erdiff

v0.9.4

Published

Database Entity Relation Diagramming tool with diffing support for diagrams and stored procedures

Downloads

11

Readme

ERDiff

generate Entity Relationship Diagram with differences

DESCRIPTION

A Database diffing and diagramming tool. Generate diffable snapshots of your schema or generate diffs between versions viewable in a browser. Use it to compare environments before deploys or as part of your process(pull requests, CI, Deployments, etc). The diffs include views and tables with relations plus stored procedures. There are a few ways to run the tool:

  • snapshot - save ERD + stored procedures as a single html file
  • save snapshot - save schema from a database
  • online diff - diff two active databases
  • snapshot diff - diff two saved schemas
  • online vs snapshot diff - diff an active database vs a snapshot
  • sequential diff - save schema from a database, modifify the database and diff the current(new) schema against the saved schema.

EXAMPLE

The output in the example directory includes the html / view page on github output as well as snapshot json and graphviz output.

Example graph rendered showing a legend, three tables, and one view with colors indicating changes where a column was added, a column was removed and the view is new

Example stored procedure diff showing colored text indicating unchanged, removed, and added lines to a very silly stored procedure

INSTALL

Install globally on your system with npm sudo npm install -g erdiff or yarn sudo yarn global add erdiff

To use it in a project npm install erdiff or yarn add erdiff

USAGE

Example diffing two postgres databases staging-host and prod-host

$ erdiff -s public -s otherschema -c 'postgres://user@pass:staging-host:5432/database' -p 'postgres://user@pass:prod-host:5432/database' > output.html

Example of diffing the same database at different times, this could be done as part of a CI process

# migrate database to revision A
$ export DB_CURRENT=mysql://user@pass:localhost/database
$ export DB_SCHEMA=first,second,third
$ erdiff -q -f main-branch.schema
# migrate databse to revision B
$ erdiff -p main-branch.schema > output.html

Dot generation from stored json

Graphvis output can be generated for any schema as well as a diff between schemas. Specify a single(current) schema to simply generate a normal Entity Relation Diagram, or specify two schemas to generate a diagram with diff information.

$ cd example
$ ../index.js -c current_schema.json -q -d current_dot.gv
$ ../index.js -c previous_schema.json -q -d previous_dot.gv
$ ../index.js -c current_schema.json -p previous_schema.json -q -d diff_dot.gv

OPTIONS

-c, --current=current (required) mysql connection url or json file to generate ERD from, when diffing this is the new schema

-d, --dot=dot save graphviz dot file

-f, --save=save save schema data for diffing later

-p, --previous=previous mysql connection url or json file to using when diffing, used as the previous schema

-q, --quiet do not output svg to stdout

-s, --schema=schema schema(s) to graph and optionally diff, use multiple times to include more than one schema

--help show CLI help

ENVIRONMENT VARIABLES

  • DB_CURRENT environment version of -c option
  • DB_PREVIOUS environment version of -p option
  • QUIET environment version of -q option
  • DB_SCHEMA environment version of -s option, use comma seperated list to include more than one schema
  • SAVE_SCHEMA environment version of -f option