Why use migrations?

Published 4 months ago by ITellMyselfSecrets

I read a lot about Migration and also watched some vides, but I still don't get it why we need it? I am using PHPMyAdmin and that works fine for me. Any good arguments to use migrations?

Best Answer (As Selected By ITellMyselfSecrets)
bobbybouwmann

You can see migrations as the version control for your database. It keeps a record of how your database was created and updated in time. It's also useful if you work with multiple persons. Using migrations you don't have to export databases or describe how to change the columns. Just run the migrations and you're done.

Alternative solutions are keeping a database dump in your project, however if you work with others you could have conflicts.

bobbybouwmann

You can see migrations as the version control for your database. It keeps a record of how your database was created and updated in time. It's also useful if you work with multiple persons. Using migrations you don't have to export databases or describe how to change the columns. Just run the migrations and you're done.

Alternative solutions are keeping a database dump in your project, however if you work with others you could have conflicts.

ITellMyselfSecrets

I will look into using migrations from now on, thanks!

Cronix
Cronix
4 months ago (482,290 XP)

Yeah, so your schema is in version control along with the rest of your code. Also, if you ever have other people work on it it's a lot easier than having to send the schema around and keep everybody in sync for every change you make. When you're dealing with local dev+testing+production servers, it's a lot easier to keep everything in sync as well and not forget to update something. Once you have a major error, you'll understand ;)

rsvb
rsvb
4 months ago (7,350 XP)

I tried the migrations, but I do not like it at all, but I develop not in a team.

It has to do also with local development, what I also don't like lol.

Cronix
Cronix
4 months ago (482,290 XP)

Oh, another thing... migrations can be run automatically as part of your deployment script, so you don't have to manually do anything to the database when using automatic deployment tools. If you don't use migrations, you'd have to manually sync your db changes to all servers.

Like I use laravel forge. All I have to do is push something to my master branch in github and it automatically deploys the code to the servers and runs the migrations.

Please sign in or create an account to participate in this conversation.