2017 © Pedro Peláez
 

library laravel-migrate-fresh

A command to build up the database from scratch

image

spatie/laravel-migrate-fresh

A command to build up the database from scratch

  • Thursday, February 15, 2018
  • by Spatie
  • Repository
  • 6 Watchers
  • 161 Stars
  • 110,083 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 25 Forks
  • 0 Open issues
  • 20 Versions
  • 14 % Grown

The README.md

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

An artisan command to build up the database from scratch

Latest Version on Packagist Software License Build Status Quality Score StyleCI Total Downloads, (*1)

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., (*2)

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., (*3)

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., (*4)

Postcardware

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., (*5)

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium., (*6)

The best postcards are published on our website., (*7)

Requirements

This command supports MySQL, sqlite, PostgreSQL and MS SQL databases., (*8)

Note: the migrate:fresh command is included by default in Laravel 5.5., (*9)

Installation

You can install the package via composer:, (*10)

composer require spatie/laravel-migrate-fresh

Next add the Spatie\MigrateFresh\Commands\MigrateFresh class to your console kernel., (*11)

// app/Console/Kernel.php

protected $commands = [
   ...
    \Spatie\MigrateFresh\Commands\MigrateFresh::class,
]

Usage

This command will drop all tables from your database and run all migrations., (*12)

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., (*13)

By tagging on the seed option all seeders will run as well., (*14)

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., (*15)

bash php artisan migrate:fresh --force, (*16)

Events

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

  • 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

Please see CHANGELOG for more information what has changed recently., (*18)

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., (*19)

bash $ composer test, (*20)

Contributing

Please see CONTRIBUTING for details., (*21)

Security

If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker., (*22)

Credits

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., (*23)

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., (*24)

License

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

The Versions

15/02 2018

dev-master

9999999-dev https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

15/02 2018

1.5.3

1.5.3.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

15/02 2018

dev-analysis-qM5bj2

dev-analysis-qM5bj2 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

06/02 2018

1.5.2

1.5.2.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

23/08 2017

1.5.1

1.5.1.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

23/08 2017

dev-fix-sqlite-in-memory-database

dev-fix-sqlite-in-memory-database https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

06/07 2017

1.5.0

1.5.0.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

05/07 2017

1.4.5

1.4.5.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

13/06 2017

dev-revert-42-master

dev-revert-42-master https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

03/05 2017

1.4.4

1.4.4.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

21/04 2017

1.4.3

1.4.3.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

13/04 2017

1.4.2

1.4.2.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

22/03 2017

1.4.1

1.4.1.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

09/03 2017

1.4.0

1.4.0.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

04/03 2017

1.3.1

1.3.1.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

13/01 2017

1.3.0

1.3.0.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

11/01 2017

1.2.0

1.2.0.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

10/01 2017

1.1.0

1.1.0.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

09/01 2017

1.0.0

1.0.0.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh

09/01 2017

0.0.1

0.0.1.0 https://github.com/spatie/laravel-migrate-fresh

A command to build up the database from scratch

  Sources   Download

MIT

The Requires

 

The Development Requires

database eloquent spatie migrate fresh laravel-migrate-fresh