PHPackages                             spatie/laravel-migrate-fresh - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. spatie/laravel-migrate-fresh

Abandoned → [laravel/framework](/?search=laravel%2Fframework)ArchivedLibrary[Database &amp; ORM](/categories/database)

spatie/laravel-migrate-fresh
============================

A command to build up the database from scratch

1.5.4(7y ago)181336.8k↓33.3%243MITPHPPHP ^7.0

Since Jan 9Pushed 6y ago5 watchersCompare

[ Source](https://github.com/spatie/laravel-migrate-fresh)[ Packagist](https://packagist.org/packages/spatie/laravel-migrate-fresh)[ Docs](https://github.com/spatie/laravel-migrate-fresh)[ RSS](/packages/spatie-laravel-migrate-fresh/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (18)Used By (3)

The migrate:fresh command is included by default since Laravel 5.5.
-------------------------------------------------------------------

[](#the-migratefresh-command-is-included-by-default-since-laravel-55)

An artisan command to build up the database from scratch
========================================================

[](#an-artisan-command-to-build-up-the-database-from-scratch)

[![Latest Version on Packagist](https://camo.githubusercontent.com/be81bcf1c8d6ebe28804c568134b3a7ea5d7d4dc69f28117adce47cd0d41c29e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d6d6967726174652d66726573682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-migrate-fresh)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/ecd6be59ad4083f62dffa8170761875d15e07a5c31f3461f5d79f834ef8c7d03/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7370617469652f6c61726176656c2d6d6967726174652d66726573682f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/spatie/laravel-migrate-fresh)[![Quality Score](https://camo.githubusercontent.com/64657236e737537195cd3c198ff8337fd3f3dcf0927553d8bece42383ca486a6/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7370617469652f6c61726176656c2d6d6967726174652d66726573682e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/spatie/laravel-migrate-fresh)[![StyleCI](https://camo.githubusercontent.com/66de009232c96e03682c116270b027f278c757958fc8ab0fe3e00c39c8defe44/68747470733a2f2f7374796c6563692e696f2f7265706f732f37383432383032352f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/78428025)[![Total Downloads](https://camo.githubusercontent.com/472809621ea9f84a001bf005ad7f89f291b0096093283c815069b8096a960cf6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d6d6967726174652d66726573682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-migrate-fresh)

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.

Postcardware
------------

[](#postcardware)

You're free to use this package (it's [MIT-licensed](LICENSE.md)), 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](https://spatie.be/en/opensource/postcards).

Requirements
------------

[](#requirements)

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

*Note: the `migrate:fresh` command is [included by default](https://laravel-news.com/migrate-fresh) in Laravel 5.5.*

Installation
------------

[](#installation)

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 = [
   ...
    \Spatie\MigrateFresh\Commands\MigrateFresh::class,
]
```

Usage
-----

[](#usage)

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
```

### Events

[](#events)

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

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

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
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

Initial code to drop all tables in a Postgresql db was provided by [Jonathan Reinink](https://gist.github.com/reinink) and reviewed by [Peter Matseykanets](https://github.com/pmatseykanets). Peter also added support for Sqlite.

About Spatie
------------

[](#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](https://spatie.be/opensource).

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity50

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 78.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~37 days

Recently: every ~104 days

Total

17

Last Release

2821d ago

Major Versions

0.0.1 → 1.0.02017-01-09

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (74 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (3 commits)")[![pmatseykanets](https://avatars.githubusercontent.com/u/779965?v=4)](https://github.com/pmatseykanets "pmatseykanets (2 commits)")[![jakub-klapka](https://avatars.githubusercontent.com/u/5950996?v=4)](https://github.com/jakub-klapka "jakub-klapka (2 commits)")[![federicogodan](https://avatars.githubusercontent.com/u/5318038?v=4)](https://github.com/federicogodan "federicogodan (1 commits)")[![introwit](https://avatars.githubusercontent.com/u/11228182?v=4)](https://github.com/introwit "introwit (1 commits)")[![jonphipps](https://avatars.githubusercontent.com/u/12743?v=4)](https://github.com/jonphipps "jonphipps (1 commits)")[![Matthijsvdorp](https://avatars.githubusercontent.com/u/11853291?v=4)](https://github.com/Matthijsvdorp "Matthijsvdorp (1 commits)")[![msonowal](https://avatars.githubusercontent.com/u/6334484?v=4)](https://github.com/msonowal "msonowal (1 commits)")[![prolonginc](https://avatars.githubusercontent.com/u/10747618?v=4)](https://github.com/prolonginc "prolonginc (1 commits)")[![redalpha01](https://avatars.githubusercontent.com/u/21954633?v=4)](https://github.com/redalpha01 "redalpha01 (1 commits)")[![rojtjo](https://avatars.githubusercontent.com/u/1123887?v=4)](https://github.com/rojtjo "rojtjo (1 commits)")[![brnpimentel](https://avatars.githubusercontent.com/u/6596579?v=4)](https://github.com/brnpimentel "brnpimentel (1 commits)")[![skyrpex](https://avatars.githubusercontent.com/u/1077520?v=4)](https://github.com/skyrpex "skyrpex (1 commits)")[![Broutard](https://avatars.githubusercontent.com/u/1552045?v=4)](https://github.com/Broutard "Broutard (1 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (1 commits)")[![drbyte](https://avatars.githubusercontent.com/u/404472?v=4)](https://github.com/drbyte "drbyte (1 commits)")

---

Tags

artisandatabasedebugeloquentlaravelmigrationsphpspatiedatabaseeloquentmigratefreshlaravel-migrate-fresh

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/spatie-laravel-migrate-fresh/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-laravel-migrate-fresh/health.svg)](https://phpackages.com/packages/spatie-laravel-migrate-fresh)
```

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M191](/packages/spatie-laravel-backup)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[erjanmx/laravel-migrate-check

A command to check for pending migrations. Exits with non-zero code if there are any

54273.8k1](/packages/erjanmx-laravel-migrate-check)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
