Mr. Mike
Mr. Mike

Reputation: 453

How to automatically update migration file based on updated model in Laravel

Can we update our migration file based on model where we have updated? I know we have command php artisan make:model modelname --m to create model and migration in same time. But when i updated the model, the migration still same (cannot updated automatically)?

Upvotes: 2

Views: 1267

Answers (2)

user3010273
user3010273

Reputation: 900

You should not be changing existing migrations! What if there's another developer working on the project and you changed the migration, merged it to the main branch and then he's left wondering why won't his database run?

Always create new migrations instead of modifying previous ones. Otherwise you will break other people's installations.

Upvotes: 1

user5520186
user5520186

Reputation:

There is currently no command for achieving this.

However, it is not recommended to update your migrations at all. You should change your database layout with a new migration instead of an updated old, so your database can keep track of changes.

Upvotes: 3

Related Questions