Categories
Programming

PHP library for database version control

DBV is a library for PHP that helps manage changes to your database. Various open source projects do this in different ways. You can go the simple route of manually keeping a series of SQL files that must be executed in order. One big downside is needing to remember the conventions and following them. Plus, you must keep track of which patches have been applied.

You can automate updates and tie them to release numbers. This is how Expression Engine does it. You just need to manage your release numbers.

Another way to do it is to write a PHP script that detects the database state and executes ALTER statements as necessary. I made a solution like that from scratch before.

It looks like DBV is more sophisticated than any of these solutions.

dbv.php: Database version control, made easy!

Make sure you and your team always have the same schema structure for tables, views, procedures, etc.

Create changeset scripts and queries, commit them to your source control system, and share them with your team.

New changeset scripts are highlighted, so you know your database is in need of an update.

Something wrong with a changeset script? Fix it directly in the application interface.

Not using MySQL, or any other of the bundled DBMS adapters? Writing your own is as easy as pie!