rjhilgefort
5/12/2020 - 11:23 PM

NodeJS Schema Migrations 2020

Research / Prior Art

Looks like most packages that exist for NodeJS loosely do what I described on the epic, which is good. I found there to be three major ones and here's my impressions of each.

db-migrate

https://db-migrate.readthedocs.io/en/latest/

Stars: 1.9K

Overall, this appears to be the most popular with 1.9K stars, highest rank in multiple google searches, and even has a docs site. Looks to be actively maintained. I read through all their docs and while it looks like it is fully featured, it lacks a driver for ArangoDB (not surprised) and creating your own driver doesn't look all that straight forward. I couldn't find any docs describing the process at all actually. It does sound possible though. It looks a little long in the tooth based on how some of the docs read.

A big plus with this library is that their CLI is the strongest of the frameworks I looked at.

node-migrate

https://github.com/tj/node-migrate

Stars: 1.2K

This is extremely similar to db-migrate with all the same features, but has a better story for creating your own "custom state storage". This is a strong contender as an option we go with.

node-pg-migrate

https://github.com/salsita/node-pg-migrate

Stars: 693

Saw this pop up on a couple blogs as an up-and-coming solution, but is Postgres only. Seems like their philosophy is to only support one thing and do that well. Not really entertaining this as it seems like we'd fight with it too much.

umzug

https://github.com/sequelize/umzug

Stars: 1.1K

Looks to be the freshest framework on the block. It's got the same up/down definitions and sync commands as all the others. It has the best story for creating a custom storage manager. It's written in TS and would allow for us to interact with it in TS which is a big plus. Lastly, it's the one with the strongest trend line lately and seems to be the go-to these days. The biggest con for this is that it doesn't have a CLI story so we'll have to make our own CLIs, but that's not a huge deal.

Conclusion

I think umzug looks the best despite not having a CLI story. I'm going to move forward with this library and make tickets around what it will take to build around this library.

Updated Conclusion

As I started to make tickets, I took a second look and I think node-migrate is going to be a better choice. Despite the popularity of umzug, which I think is just because of sequelize, I think node-migrate suits us better because:

  • The db instantiation is just a singleton that lives outside the up/down definitions. This jives better for us because we already use a config management system to determine our environments.
  • It already has a CLI story
  • There's no TS, but I hope that won't be a big deal because of the way the db is setup. The other advantages out-weigh this anyhow.