Getting Started with Laravel Migrations: A Beginner's Guide


If you're just starting with Laravel, you've likely heard the term "migrations" — and you might be wondering:
What are Laravel migrations and why should I care?
This post will walk you through the basics, helping you confidently create and manage database schemas using Laravel’s migration system.
🚀 What Are Migrations?
Migrations are Laravel’s way of version-controlling your database schema using PHP code instead of raw SQL.
Think of them like Git for your database tables:
You can create, modify, and remove tables through migration files.
You can share those changes with your team.
You can track and rollback changes easily.
They make your database predictable, portable, and team-friendly.
How to Create a Migration
Run the following Artisan command in your Laravel project:
php artisan make:migration create_users_table
This will generate a file in the database/migrations/
directory, named something like:
2025_07_19_000000_create_users_table.php
The timestamp keeps migrations in order — Laravel runs them sequentially.
Writing the Schema
The generated migration file will have two methods: up()
and down()
.
Here’s an example:
public function up(): void {
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamps();
});
}
public function down(): void {
Schema::dropIfExists('users');
}
up()
: defines what happens when you run the migration.down()
: defines how to revert that change (rollback).
This design ensures changes can be reversed when needed.
Running the Migration
To apply all pending migrations:
php artisan migrate
Laravel will execute the up()
methods of all migration files that haven’t been run yet.
Need to rollback the last migration batch?
php artisan migrate:rollback
Want a fresh start?
php artisan migrate:fresh
👉 These commands are life-savers when experimenting or testing.
🧩 Making Schema Changes Later
Let’s say you want to add a new column to the users
table:
php artisan make:migration add_profile_to_users_table
Inside the file:
public function up(): void {
Schema::table('users', function (Blueprint $table) {
$table->text('profile')->nullable();
});
}
public function down(): void {
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('profile');
});
}
✅ Best Practices for Migrations
Use clear, descriptive names (
create_users_table
, notsomething_table
)Always define the
down()
method to support rollbacksUse migrations along with seeders for a complete local setup
Use
--create=
and--table=
options to scaffold with intent
Why Migrations Matter
In real-world applications, databases evolve constantly.
Migrations make schema changes:
Predictable — you're not modifying tables manually
Portable — changes are shared through code
Safe — rollbacks are built-in
Trackable — full history lives in Git
Once you start using them, you won’t go back to manual DB changes.
Final Thoughts
Laravel migrations are one of the most powerful tools in the framework — and they’re built to be beginner-friendly.
So go ahead:
Create a new migration
Write your schema
Run
php artisan migrate
Start building!
Have any questions about migrations? Drop them in the comments.
🔗 Resources
🧩 GitHub Example
Want a working demo? 👉 Laravel Controllers Example on GitHub
🙌 Let’s Connect!
If you enjoyed this article, share your thoughts or ask questions below. Follow me on LinkedIn / Substack / GitHub for more beginner-friendly Laravel tutorials.
Subscribe to my newsletter
Read articles from Rohit Dhiman directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Rohit Dhiman
Rohit Dhiman
Laravel developer with 10+ years experience building scalable backends, APIs, and full-stack systems. 💡 Expect posts about: Laravel design patterns Stripe & Twilio integrations RESTful API tips Docker for Laravel devs AWS setups for backend scaling Let’s learn & build together 🚀