I created [sqlpatch](https://github.com/LuvDaSun/sqlpatch) for migrating your database. I kind-of automates what you are describing in this article.

You build your database as a set of sql files. Files may depend on other sql files. Sqlpatch takes care of sorting your sql files based on the dependencies and make sure that every sql file is executed exactly once.

Currently it supports postgres and sqlserver dialects, expect support for mysql soon!