Laravel Migrations Tutorial — Up, Down & Rollback Explained

Опубликовано: 24 Сентябрь 2026
на канале: Dev Diaries WD
24
1

Laravel migrations are version control for your database — define and change your tables in PHP, commit them to Git, and let your whole team run the exact same schema with one command. In this first Laravel interview episode we build an employees table, run it, then add a column with a second migration.

What you'll learn:
What migrations are and why they beat manual SQL changes
make:migration and the create vs alter table templates
Columns: string, integer, text, unique() and nullable()
The up() and down() methods — apply vs roll back
php artisan migrate, migrate:rollback and migrate:status
Adding a column to an existing table with Schema::table()

Commands used:
php artisan make:migration create_employees_table
php artisan migrate
php artisan make:migration add_department_to_employees_table
php artisan migrate

Tip: always fill in down() so a rollback cleanly reverses your change (dropColumn / dropIfExists).

Full code and write-up: https://devdiarieswd.com/laravel-inte...

New Laravel interview questions every upload — one concept at a time.
Subscribe:    / @devdiarieswithdanny  

#laravel #php #laravelmigrations #database #mysql #webdevelopment #laraveltutorial #coding