← Laravel learning pathLaravel · Module 6 of 10
Migrations and seeders
Version your database schema and fill test data.
📖 Key ideas
- Migrations define tables in PHP: Schema::create("posts", ...).
- Run: php artisan migrate; undo: migrate:rollback.
- Seeders insert starter data: php artisan db:seed.
- Factories generate fake data for tests.
- 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