Use php artisan schema:dump to collapse hundreds of old migration files into a single SQL schema file while preserving new migrations.
As applications age, running hundreds of individual database migration files slows down test suites and deployment setups. Use schema:dump to collapse old migrations into a clean schema file.
# Dump schema and prune old migration files
php artisan schema:dump --prune
# Schema is saved to database/schema/mysql-schema.sql
- Collapses old migration files into a single database/schema dump file
- Slashes migration execution time during automated test suite runs
- New migration files created after squashing run sequentially after the schema dump
Related Tips
View all tips →Detect AI Agents in Laravel with AgentDetector and PAO
Laravel's AgentDetector detects whether an AI coding agent is interacting with your app, and PAO optimizes CLI output for agents.
Use config() Instead of env() in Application Code
Call env() only inside configuration files and use config() throughout your application code to prevent missing values when configuration is cached.