Back

Not sure if this is a tip or what, but...

✅ When creating a migration via CLI, if you don't want to press "_" after each word, just pass the name in the quotes: `php artisan make:migration "create users table"`

✅ If you want to CREATE a table, then your migration name must look like `create_users_table`;

✅ if you want to ADD COLUMNS to the existing table (or delete/change), then your migration file name must look like `add_some_columns_to_users_table` (note the `_users_table` at the end of the file).

In that case, Laravel will automatically try to resolve the table name for you, so you don't have to write `Schema::table('...')` or `Schema::create('...')` manually ever again! :)

1

140

  • No matching results...
  • Searching...

/ 1000

Poll Options

For create table I prefer to use make:model Model -m 🙃

But yes, if I need Only a table, with double quote is the best way, for sur.

1

125

Me too, but in some cases, the model already exists and migrations are not in place (like in the project I'm working on atm).

72