What is the use of laravel Squashing Migrations schema:dump command

What is the use of laravel migration schema:dump command. How to reduce laravel's many migration files to a single file. "php artisan schema:dump" command in laravel 8, laravel 9. Here we discuss what is Squashing Migrations concept.


Squashing Migrations schema:dump command

A larage laravel project have many migration files these make slowing down your tests. In laravel 8 Taylor Otwell added new feature Schema Dump for reducing migration files.

Why we use Schema Dump

When we have lot migrations files it take more time in tests and run all migration in new database. after Schema Dump we have only one file to run its make faster execution.

How to work schema:dump command

When we run php artisan schema:dump command it make a schema file in "database/schema" folder. Now when we migrate our database laravel runs the schema file's SQL statements first. after executing the schema file rest of the migrations files run.

php artisan schema:dump

schema:dump --prune command

If you want to delete all migrations files that are schema SQL create in single file run php artisan schema:dump --prune command. Before executing this command take a backup of the migration folder.

php artisan schema:dump --prune

Note: Migration squashing concept only support MySQL, PostgreSQL, and SQLite databases

php laravel developer anmol sharma

Anmol Sharma

I am a software engineer and have experience in web development technologies like php, Laravel, Codeigniter, javascript, jquery, bootstrap and I like to share my deep knowledge by these blogs.

Random tutorial links