Database Migrations for PHP5
One of the cool things I like about Ruby on Rails is the use of “migrations” for maintaining your DB. Migrations have proven to be pretty handy in keeping a local database in sync with the work of other developers.
In addition, it is the primary method of application deployment. Because migrations are incremental and they are done in a structured manner, it is a great way of pushing out new DB changes to the production database servers.
A colleague has been working on a new PHP-based project and was lamenting the lack of migrations. In retrospect, I wished a migrations framework was available for PHP, for all my projects.
So I sat down and wrote my own.
“Ruckusing Migrations” is a migrations framework for PHP5 (PHP5 only - absolutely no plans for PHP4 compatibility). The framework is very modular and makes extensive use of the object-oriented features of PHP5, namely interfaces and reflection.
But onto the good stuff. Some features of the framework:
- Portability: it was written with portability in mind. All DB calls go through an adapter interface so support for new RDBMS should be very easy. Currently, only MySQL support is available out of the box.
- Generic task interface. The framework uses task files, which are just PHP5 classes which adhere to a basic naming convention. Because these follow a convention they are automatically loaded and registered into the framework for use.
- Rich API for database manipulation. Database-level operations, table-level operations, column-level operations and execution of arbitrary queries is all supported..
- More good stuff.
Release 1.0 is on Google Code and can be checked out via anonymous SVN.
See the project homepage for downloads and documentation.
Of course, please contact me with any questions or comments.
codycaughlan % gmail % com
September 10th, 2007 at 5:52 am
Cody Caughlan’s Blog: Database Migrations for PHP5…
…
September 10th, 2007 at 7:48 am
[…] Caughlan has created a project that brings one of the popular features of Ruby on Rails to the world of PHP5 - database […]
September 10th, 2007 at 8:56 am
Excellent work! Looks very promising and is just what I’ve needed numerous times when dealing with complex projects.
November 7th, 2008 at 9:35 am
Rails recently implemented migrations using timestamps to help avoid versioning conflicts with multiple developers. Any thoughts on changing your code to support this method as well?
November 7th, 2008 at 11:24 am
Dave-
Yes, I definitely want to move towards the timestamp-ed style of migrations. You’re right in that it is a big help in preventing version conflict. Look for this feature shortly, maybe in an upcoming 2.3 or 2.4 release?