2

I'm learning laravel and in most of tutorials they are making migrations using artisan. I skip that step and I'm working directly on a database. I don't know for what can a migration be useful. so the question is: what is exactly a migration?

4

1 回答 1

3

If you are the lone developer, you may not get much use out of it.

But imagine you have multiple developers each with your app stored locally on their machine. What happens when you need to make an update to the database? You would have to make the update, send the query to each other developer, and they would have to run the query on their machines. Once you get a decent amount of developers making changes to the database, this process can quickly become overwhelming and it's only a matter of time before people start missing the changes.

With migrations, all of the changes are stored as files, so in order for a developer to catch up, all they need to do is fetch the code changes and run php artisan migrate and all the work is done for them. This means all your developers are consistently working with the same database structure.

于 2014-03-20T11:48:30.227 回答