← Laravel learning path
Laravel · Module 6 of 10

Migrations and seeders

Version your database schema and fill test data.

📖 Key ideas

  1. Migrations define tables in PHP: Schema::create("posts", ...).
  2. Run: php artisan migrate; undo: migrate:rollback.
  3. Seeders insert starter data: php artisan db:seed.
  4. Factories generate fake data for tests.
  5. migrate:fresh --seed rebuilds the DB (dev only).
💡 Real-life example: Migrations are a recipe history: every cook can rebuild the same dish step by step.
MigrationPHP file defining schema changes
SeederInserts sample data
FactoryGenerates fake model data
rollbackReverts the last migrations