0

My team and I are currently using Git to manage our version control. We want to start using it for our migration-less systems too, but the issue we're having is that of absolute URLs embedded in the (MySQL) database. Using a shared database breaks our local environments. Another issue is changes performed on identical tables, though we have yet to think that one out properly.

We tried doing it through a mysqldump, then replacing all absolute URLs through sed, but this is very finnicky. We're wondering if there's a better way to do it.

I can't imagine we are the first people having this question. But either I have the absolutely poorest investigatory skills, or there really isn't all that much information about this.

Could anybody point me into the right direction?

Thanks!

Thierry
  • 101
  • 1
  • 7
  • I've never come across "migration-less system" and Google only finds this question. Can you define please? If your question is answered here: http://stackoverflow.com/questions/115369/do-you-use-source-control-for-your-database-items please consider closing. – Neville Kuyt Oct 18 '16 at 13:22

1 Answers1

0

To update URLs in database simply use UPDATE query with REPLACE function.

UPDATE your_table SET url = REPLACE(url, 'http://example.com/', '/');

(Don't forget to make backups before you do this.)


To upgrade database schema from one version to another I recommend simple upgrade scripts and slightly smart launcher. Point is that each developer has his own database and when he changes database schema, he does that using a SQL script. The script is committed together with changes in source code. Later, when another developer fetches new version, he runs the new migration scripts to get his database upgraded.

I have very good experience with this aproach on many projects. Take a look at my Changelog.sql tool.

Josef Kufner
  • 2,851
  • 22
  • 28