Laravel Migrations Deep Dive — a practical guide to Laravel migration best practices with clear examples you can reuse in real projects.
Laravel Tutorial Series (23/27). Prefer one page? Read the complete Laravel tutorial (all 27 topics).
Short description
Migrations are more than `migrate` once — learn rollback strategy, modifying columns, and production safety.
Useful commands
php artisan migrate
php artisan migrate:rollback
php artisan migrate:rollback --step=1
php artisan migrate:fresh --seed # wipe + remigrate (dev only)
php artisan migrate:status
Rename / change columns (doctrine/dbal may be required on older Laravel)
Schema::table('posts', function (Blueprint $table) {
$table->renameColumn('body', 'content');
});
Raw SQL inside migration
DB::statement('ALTER TABLE posts ADD FULLTEXT(title, content)');
Production tips
• Take a DB backup first
• Avoid `migrate:fresh` on production
• Keep migrations reversible when possible
• Test rollback on staging