PHP - Mechanisms for tracking DB schema changes

What are the best methods for tracking and/or automating DB schema changes? Our team uses Subversion for version control and we've been able to automate some of our tasks this way (pushing builds up to a staging server, deploying tested code to a production server) but we're still doing database updates manually. I would like to find or create a solution that allows us to work efficiently across servers with different environments while continuing to use Subversion as a backend through which code and DB updates are pushed around to various servers.

Many popular software packages include auto-update scripts which detect DB version and apply the necessary changes. Is this the best way to do this even on a larger scale (across multiple projects and sometimes multiple environments and languages)? If so, is there any existing code out there that simplifies the process or is it best just to roll our own solution? Has anyone implemented something similar before and integrated it into Subversion post-commit hooks, or is this a bad idea?

While a solution that supports multiple platforms would be preferable, we definitely need to support the Linux/Apache/MySQL/PHP stack as the majority of our work is on that platform.

This question and answers originated from www.stackoverflow.com
Question by (8/4/2008 9:31:40 PM)

Answer

In the Rails world, there's the concept of migrations, scripts in which changes to the database are made in Ruby rather than a database-specific flavour of SQL. Your Ruby migration code ends up being converted into the DDL specific to your current database; this makes switching database platforms very easy.

For every change you make to the database, you write a new migration. Migrations typically have two methods: an "up" method in which the changes are applied and a "down" method in which the changes are undone. A single command brings the database up to date, and can also be used to bring the database to a specific version of the schema. In Rails, migrations are kept in their own directory in the project directory and get checked into version control just like any other project code.

This Oracle guide to Rails migrations covers migrations quite well.

Developers using other languages have looked at migrations and have implemented their own language-specific versions. I know of Ruckusing, a PHP migrations system that is modelled after Rails' migrations; it might be what you're looking for.

Answer by

Find More Answers
Related Topics  php  mysql  database  svn  migration
Related Questions
  • Right tool for tracking DB structure changes

    Right now i have a PHP project and i track all changes in code by SVN. I would also like to track changes made in database structure. Which is the right tool to use ?
  • Version track, automate DB schema changes with django

    I'm currently looking at the Python framework Django for future db-based web apps as well as for a port of some apps currently written in PHP. One of the nastier issues during my last years was keep…
  • DB Schema For Chats?

    i need to store chat conversations in a database schema. the way i would use this database is i would post chats on a website. each chat would not be more than about 20 responses. can someone please…
  • System for tracking changes in whois records

    What's the best storage mechanism (from the view of the database to be used and system for storing all the records) for a system built to track whois record changes? The program will be run once a d…
  • Suggested DB Schema for Quotes

    How would you save the quote products in a database? Serialize data? http://cl.ly/6419969e30cd26e2f32a They can create however many rows they want... It's for a quote system. Create a quote wi…
  • Tracking data changes

    I work on a market research database centric website, developed in PHP and MySQL. It consists of two big parts – one in which users insert and update own data (let say one table T with an user_id fi…
  • Suggestion for better relational DB Schema

    I am here to design a relational database schema that models polling and users. Each category can have one or many questions. Each user can participate only once at each category, and can poll (or n…
  • Tracking changes to db fields while using ORM

    I want to track the changes made to every column in a particular table. I thought of storing the changes in another table with the following columns: id, field, and data where field (string value) i…
  • Suggested DB Schema for a Lunchtime Reimbursement Application

    I am designing a web-based smartphone app with jqTouch. The idea is to be able to: Track who owes whom lunch Track debt over time Transfer debt from one person to another This sounds c…
  • DB schema migration tool for CodeIgniter

    Is there a good tool for managing changes to MySQL schemas? Either standalone, or integrating with the CodeIgniter framework. I'm coming at this idea with experience using CakePHP's DB migration too…