Hacker News new | ask | show | jobs
Ask HN: (What) do you use (for) automatic DB migrations in PHP?
2 points by ron77 5669 days ago
So I finally wanted to organize things better and handle DB migrations in more automatic way. I did some research and surprisingly didn't find what I was expecting to find.

I'd like a tool which can create migration files automatically basing on actual DB tables. Let it be aware of previous DB schema, examine new DB schema, create diffs and put them in a migration file.

I found many great migration solutions which handle managing revisions, executing migrations up and down, but all of them require you to manually write code for DB changes. There has to be something better than this.

What do you recommend?

1 comments

mysqldiff.pl generates the diffs you refer to, but I never implemented a fully automated process, because I never trusted that nothing would go wrong. That does not stop me from using the output in the migration script though, so you should be able to do the same.
Thanks, I'll try it!

Sure, I don't mean a fire&forget thing but to review migration commands. But diffs should be fine too - they'll actually require a programmer to review it, even accidentally when pasting the output to the migration script.