3

I'm trying to get a workflow on database synchronization. Right now:

  1. We create a database.

  2. The database goes to production.

  3. Later... we realise that we need to change the database structure. We change that locally.

  4. Once that is done, we upload to the production.

If this is common among developers, what methods do you use to deal with this, without losing data already introduced on the production side?

Jason Plank
  • 2,336
  • 5
  • 31
  • 40
MEM
  • 30,529
  • 42
  • 121
  • 191

1 Answers1

3

You should be placing your database schema under version control. There are lots of tools available to help you with this.

Check out this other previous question on the topic for a few PHP-specific options. Database migrations are usually part of code rollouts. Look into build tools to help make this process more automated. Phing is a popular option.

Community
  • 1
  • 1
Charles
  • 50,943
  • 13
  • 104
  • 142
  • Thank you. At least now I have a prespective about where should I look at. I'm using Capistrano with railsless-deploy and I'm totally new to git. Not sure if that article is for me at the moment. Oh well. :) Thanks. – MEM Apr 01 '11 at 17:02
  • I've seen Capistrano used in conjunction with PHP before, but I don't have any specific resources for you other than knowing it's not something weird to leverage. – Charles Apr 01 '11 at 17:12
  • Please correct me here. I place my db schema under version control. Ok. I will use a git hook for grabbing the db schema and store in a file. Each time I do a change locally, and I then commit, and then, I deploy my project files and folders, including that .sql one, *will my remote db schema change as well ?* The script that I intend to use is expressed on my question here: http://stackoverflow.com/questions/5518349/using-git-to-track-mysql-schema-some-questions Thanks in advance. Ps-Capistrano WILL deploy the committed changes, only that. I've not configured any db settings there. – MEM Apr 02 '11 at 13:34
  • I'm not sure, I don't use that specific technique. I use individual files to express the changes between database versions and a less high-tech and slick tool for the rollouts. – Charles Apr 02 '11 at 17:06