Mohamed Bouallegue
Mohamed Bouallegue

Reputation: 1362

What is migration in laravel

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?

Upvotes: 1

Views: 212

Answers (2)

Shahid Hussain
Shahid Hussain

Reputation: 1

In Laravel, migration is a way to manage your database schema using simple PHP code. It helps create and modify database tables without writing SQL queries directly, ensuring consistent and portable database structures. Migrations also enable easy version control and rollbacks for database changes.

Upvotes: -1

user1669496
user1669496

Reputation: 33118

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.

Upvotes: 3

Related Questions