Laravel Migrations Tutorial: Managing Your Database Schema
Learn Laravel migrations step by step — create tables, add columns, run and roll back migrations, and manage your database schema in code.
Migrations let you define your database structure using PHP code instead of manually creating tables in phpMyAdmin or a database GUI. This means your entire team (and every environment — local, staging, production) can share the exact same database structure through version control. Why Use Migrations? Your database schema is tracked in Git, alongside your code Easy to undo changes with rollback Teammates can rebuild the exact same database structure with one command No more manually re creating tables when setting up a new environment Setting Up Your Database Connection Before running migrations, configure your .env file: DB CONNECTION=mysql DB HOST=127.0.0.1 DB PORT=3306 DB DATABASE=laravel app DB USERNAME=root DB PASSWORD= Creating a Migration php artisan make:migration create products table This generates a timestamped file in database/migrations/ . Anatomy of a Migration File use...
Home · Projects · Articles · Developer tools · Contact