This package is abandoned and no longer maintained. The author suggests using the laravel/framework package instead.

A command to build up the database from scratch

1.5.4 2018-08-27 13:42 UTC

This package is auto-updated.

Last update: 2019-09-13 09:20:52 UTC


An artisan command to build up the database from scratch

Latest Version on Packagist Software License Build Status Quality Score StyleCI Total Downloads

Laravel has a migrate:refresh command to build up the database using migrations. To clear the database it'll first rollback all migrations by using the down method in each migration.

But what if you don't use the down method inside your projects? The migrate:refresh command will fail as the database isn't cleared first.

This package contains a migrate:fresh command that'll nuke all the tables in your database regardless of whether you've set up the down method in each migration.


You're free to use this package (it's MIT-licensed), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

The best postcards are published on our website.


This command supports MySQL, sqlite, PostgreSQL and MS SQL databases.

Note: the migrate:fresh command is included by default in Laravel 5.5.


You can install the package via composer:

composer require spatie/laravel-migrate-fresh

Next add the Spatie\MigrateFresh\Commands\MigrateFresh class to your console kernel.

// app/Console/Kernel.php

protected $commands = [


This command will drop all tables from your database and run all migrations.

php artisan migrate:fresh

Be aware that the command will knock down all tables in the database. Tables not belonging to your application will be dropped as well.

By tagging on the seed option all seeders will run as well.

php artisan migrate:fresh --seed

If the command is being executed in a production environment, confirmation will be asked first. To suppress the confirmation use the force option.

php artisan migrate:fresh --force


This package fires several events, which you can hook into to perform some extra logic rebuilding the database.

  • Spatie\MigrateFresh\Events\DroppingTables: will be fired right before dropping the first table
  • Spatie\MigrateFresh\Events\DroppedTables: will be fired right after all the tables have been dropped and before running the up steps of the migrations


Please see CHANGELOG for more information what has changed recently.


In order for the test to be run you should set up an empty mysql database laravel_migrate_fresh . The username should be root, the required password should be empty.

$ composer test


Please see CONTRIBUTING for details.


If you discover any security related issues, please email instead of using the issue tracker.


Initial code to drop all tables in a Postgresql db was provided by Jonathan Reinink and reviewed by Peter Matseykanets. Peter also added support for Sqlite.

About Spatie

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.


The MIT License (MIT). Please see License File for more information.