Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

stefr's avatar

make:model also creates a migration

Hi,

Maybe this is a newbie question. I'm just getting started. When I want to create a model I use

php artisan make:model Article

Then this is the result:

Model created successfully.
Created Migration: 2015_02_25_104828_create_articles_table

Why does it also create the Migration? This doesn't happen in the laracast movies.

0 likes
14 replies
stefr's avatar

Hi @AtoZ,

Thanks! I thought I was doing something wrong. I'm going to watch that latest video now :-)

Thanks!

cmw's avatar

I bumped into that one too. In my version it's: php artisan make:model Article --no-migration

I was wondering. Shouldn't it have been better for backwards compatibility if the option would be --add-migration ?

JeffreyWay's avatar

If you think about it, every time you make a model...you also want a migration. So it makes good sense.

If you use the laracasts/generators package, the same is true the other way around. If you generate a migration, you get a model too.

1 like
ralphmrivera's avatar

@JefferyWay, I'm using Laravel 5.1, but I'm not getting a migration and model at the same time.

php artisan make:model Task
Model created successfully.

I'm ok with this behavior, but I'm wondering why yours works differently.

mehany's avatar
Laravel Framework version 5.1.6 (LTS)

php artisan make:model test
Model created successfully.

php artisan make:model test2 --migration
Model created successfully.
Created Migration: 2015_07_09_132827_create_test2s_table
1 like
Red's avatar

Four months ago he was probably using 5.0. Since 5.1 creating migrations for models is opt-in so you would have to use the --migration flag in order to get migrations.

shanaka111's avatar

So whts the difference between a model and a migration???

prosa's avatar

@shanaka111 a model interact with the data base. is where you can declare the relationships with other tables and a migration is used to create tables in the database or modify them

rizwanjaved's avatar

Should be work as

$ php artisan make:model Settings --no-migration

Model created successfully.

arslanramay's avatar

In Laravel 5.x, you can use the following artisan command to create Model, Controller, Migration and Factory all at once in one single command.

php artisan make:model Task -a

Please or to participate in this conversation.