Creating Migrations

Generating and Structuring a Migration

make:migration prefixes the name with a timestamp and reads it to pre-fill the stub: create_customers_table yields Schema::create('customers', ...), and add_isbn_to_products_table yields Schema::table('products', ...). --create= and --table= help when the name gives no clue.

Generating the bookshop migrations one second apartPHP
for t in customers categories products orders order_items reviews; do
  php artisan make:migration "create_${t}_table"; sleep 1
done
php artisan make:migration add_isbn_to_products_table
ls database/migrations
Output
...
2026_09_23_081319_create_orders_table.php
2026_09_23_081320_create_order_items_table.php
...

Each stub returns an anonymous class (return new class extends Migration), so class names never clash. The customers stub's up() creates the table with $table->id() and $table->timestamps(), and down() calls Schema::dropIfExists('customers'); down() must undo up() exactly. A $connection property picks another connection, and a shouldRun() method returning false skips the file.

The sleep 1 matters: files made in one second sort alphabetically, putting order_items before orders, which its foreign key references.