Laravel 8 Schema Dump Command: squashing & Cleaning Migrations

Laravel 8 Schema Dump Command: squashing & Cleaning Migrations

In this post we will give you information about Laravel 8 Schema Dump Command: squashing & Cleaning Migrations. Hear we will give you detail about Laravel 8 Schema Dump Command: squashing & Cleaning MigrationsAnd how to use it also give you demo for it if it is necessary.

Laravel 8 officially released on 8th September 2020. The laravel team releases new Laravel version in every 6-month interval with major changes. As Laravel 8 Non-LTS (general version), the Laravel 8 will provide 6 months bug fixes until March 8, 2021, and 1-year security fixes until 8 September 2021.

Among the new featurs of Laravel is a new schema:dump command which allowsy you to remove old migrations and speed up the testing and CI process.

This feature solves two problems:

  • It allows you to clean old migrations in the schema folder,
  • It causes tests to run faster because Laravel doesn’t run all the migrations during testing.

You can run the command from your terminal as follows:

php artisan schema:dump# Dump the current database schema and prune all existing migrations...php artisan schema:dump --prune# Specify the connection namephp artisan schema:dump --database=pgsql

The schema:dump command makes use of the mysqldump or pgdump utiltities to dump the current state of your schema to a database/schema/{connection}-schema.mysql file.

This how the official docs describes this command:

As you build your application, you may accumulate more and more migrations over time. This can lead to your migration directory becoming bloated with potentially hundreds of migrations. If you would like, you may “squash” your migrations into a single SQL file using the the schema:dump command. Laravel will write a “schema” file to your database/schema directory. Now, when you attempt to migrate your database and no other migrations have been executed, Laravel will execute the schema file’s SQL first. After executing the schema file’s commands, Laravel will execute any remaining migrations that were not part of the schema dump.


Hope this code and post will helped you for implement Laravel 8 Schema Dump Command: squashing & Cleaning Migrations. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US