0

I'm working with another person, and we use GitHub to commit and download all changes and keep the updated files in the computer. But we have a problem, we can't do the same thing with the application's database. We try to export only the changed tables, but this isn't optimal.

My question is, if you know some software (like github or subversion) for databases, to keep all local databases updated, and combine the changes without losing data.

We're using MAMP with Mac.

tshepang
  • 12,111
  • 21
  • 91
  • 136
Evilcloud
  • 21
  • 4
  • This is probably more appropriate for programmers stackexchange or db admin stackexchange – colinro Jun 19 '14 at 08:51
  • possible duplicate of [Do you use source control for your database items?](http://stackoverflow.com/questions/115369/do-you-use-source-control-for-your-database-items) – Isaac Bennetch Jun 23 '14 at 01:44

1 Answers1

1

maybe you could use a migrationframework like http://phinx.org

then you could write your database changes to a migration file and include them on github.

Raphael Müller
  • 2,180
  • 2
  • 15
  • 20
  • Is possible to apply the changes from my local database on another one without losing data if the user change their data? thanks – Evilcloud Jun 19 '14 at 11:32
  • i think that's a little bit difficult. personally, i have different data versions, e.g. test environment, production etc. and the migrations are used to apply changes to design changes. as example: with the current version of your code you have some tables, then you write a new class which uses another table. you have to add the table via the migrationscript and commit all changes. With this mechanism you can guarantee that your code will work after the migration is applied to your database. – Raphael Müller Jun 19 '14 at 11:50
  • Migrations are the way to go, and there are lots of libraries out there. In general, you'll want to write them such that data is preserved. For example, to move a column from one table to another you'd likely want something like `begin transaction; add new column; copy data from old column to new column; drop old column; end transaction;`. Make sure to write a reverse migration too, so you can flip back and forth in development. – ChrisGPT was on strike Jun 19 '14 at 12:09