Laravel database migrations for schema management

13455
0

Migrations version control database schema changes, making them trackable and reversible. Each migration file contains up() and down() methods defining changes and rollbacks. I use the Schema builder's fluent API to create tables, add columns, define indexes, and set foreign keys. Running php artisan migrate executes pending migrations in order. The --step flag enables selective rollbacks. Migration files never edit after committing—create new ones to modify schema. For data migrations, I use seeders or separate migration files. Anonymous migrations reduce file clutter. Database-specific features use DB::statement() for raw SQL. Schema dumps capture current state for faster fresh installs. Migrations enable team collaboration without manual schema coordination.