make:migration command generates a new migration file in the database/migrations directory.
Syntax
string
required
Descriptive name for the migration (use snake_case)
Basic Usage
Create a new migration:Migration filenames are automatically prefixed with a timestamp to ensure they run in the correct order.
Generated Migration
The command creates a migration class withup() and down() methods:
database/migrations/2026_03_08_143022_create_users_table.php
Migration Structure
Class Name
The class name is automatically generated from your migration name:rawr (line 288)
Timestamp Prefix
Each migration gets a unique timestamp:rawr (line 284)
2026_03_08_143022_create_users_table.php
up() Method
Defines the changes to apply:down() Method
Defines how to reverse the changes:Naming Conventions
Table Creation
For creating new tables:Column Addition
For adding columns to existing tables:Column Modification
For modifying existing columns:Table Deletion
For dropping tables:Use descriptive names that clearly indicate what the migration does. This makes it easier to understand your database history.
Common Migration Patterns
Create Table with Columns
Add Columns to Existing Table
Create Pivot Table
Add Indexes
Modify Columns
Available Column Types
The schema builder supports various column types:Numeric
String
Date/Time
Other
Column Modifiers
Customize columns with modifiers:Foreign Keys
Define relationships between tables:Error Handling
Missing Name
Directory Creation
The command automatically creates the migrations directory if it doesn’t exist:rawr (lines 279-282)
Source Code
The migration generation logic:rawr (lines 272-315)
Workflow Example
Best Practices
Do:
- Use descriptive migration names
- Always define both
up()anddown()methods - Keep migrations small and focused
- Test rollbacks to ensure they work
- Modify existing migrations after they’ve been run
- Delete migration files
- Put business logic in migrations
- Use raw SQL unless absolutely necessary
Next Steps
Run Migrations
Execute your migrations
Make Model
Create models for your tables
Schema Builder
Learn about schema building
Seeding
Populate your database with test data