Put MySQL database under version control?
Whenever you make changes to your database, you should save those changes in a migration, that you can then later on run on other servers at the same time you update your code. But you basically got the right idea. You can write some tools to make it more automated; for example version each file, and then create a table like migration_version
in your database, which will contain the current version of the database. You can then create a migrate script that will run all the migrations required to get the database up-to-date.
Note that if you want bi-directional db versioning (so that you can revert back to previous db version too), you need to write the required queries for that too for each version.
There are also some tools that can aid you in writing the migrations, such as MySQLdiff
Note that in December 2012, you had another option: DBV (DataBase Version)
It is based on this Github project (stalled in 2018), and is a database version control web application featuring schema management, revision scripts, and more.
It has been discontinued since early 2021.