Introducing Porpoise, Database Schema Migration Script

I previously detailed a database schema migration style. Since then, I have written and open-sourced a schema migration tool called Porpoise1.

3

Porpoise diverges slightly from the style I discussed previously. Whereas the previous solutions dealt with a linear version (v1, v2, v3), Porpoise handles changesets. The linear solution works best if your entire team is working on the same source branch (ie: master or trunk). It falls apart if there is any branching involved. Since those branches will be merged in at different times, the numbering scheme can quickly get out of sync. We ended up with duplicate script numbers (even as high as five scripts with the same number). It was very difficult to determine which scripts required applying.

Our current workflow involves branching for each story or bug fix. These stories are usually self-contained. Therefore, the database changes should be self-contained. Each branch can create it’s own changeset for the database. This allows us to easily apply AND rollback changes as we move from branch to branch.

Please review the README file on Github. There may be some rough edges in the script. Please fork, modify and issue pull requests. Leave questions in the comments or contact me directly via twitter or email.

This script may not be a one-size fits all kind of solution. However, the script is pretty simple. You could use it as a base and modify it to custom fit your in-house requirements. If you decide to try it out, I would love to hear about it.

1 Why the name “Porpoise”? Because we previously attempted to implement a tool called “Manatee” at work. Long story short, that tool did not fit our workflow. A co-worker kept jokingly referring to Manatee as Porpoise. So when I created this tool, I thought I would actually make porpoise a real thing.

comments powered by Disqus