All Projects → spatie → Laravel Migrate Fresh

spatie / Laravel Migrate Fresh

Licence: mit
An artisan command to build up a database from scratch

Projects that are alternatives of or similar to Laravel Migrate Fresh

Laravel Database Encryption
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Stars: ✭ 238 (+32.96%)
Mutual labels:  eloquent, database, laravel
Laravel Artisan Dd
Quickly run some code via Artisan
Stars: ✭ 136 (-24.02%)
Mutual labels:  laravel, artisan, debug
Lada Cache
A Redis based, fully automated and scalable database cache layer for Laravel
Stars: ✭ 424 (+136.87%)
Mutual labels:  eloquent, database, laravel
Laravel Mailable Test
An artisan command to easily test mailables
Stars: ✭ 143 (-20.11%)
Mutual labels:  laravel, artisan, debug
Gorose
GoRose(go orm), a mini database ORM for golang, which inspired by the famous php framwork laravle's eloquent. It will be friendly for php developer and python or ruby developer. Currently provides six major database drivers: mysql,sqlite3,postgres,oracle,mssql, Clickhouse.
Stars: ✭ 947 (+429.05%)
Mutual labels:  eloquent, database, laravel
Laravel Eloquent Query Cache
Adding cache on your Laravel Eloquent queries' results is now a breeze.
Stars: ✭ 529 (+195.53%)
Mutual labels:  eloquent, database, laravel
Laravel Tail
An artisan command to tail your application logs
Stars: ✭ 587 (+227.93%)
Mutual labels:  laravel, artisan, debug
Laravel Translatable
A Laravel package for multilingual models
Stars: ✭ 624 (+248.6%)
Mutual labels:  eloquent, database, laravel
Eloquent Driver
A package that allows you to store Statamic entries in a database.
Stars: ✭ 28 (-84.36%)
Mutual labels:  eloquent, database, laravel
Laravel
Laravel Model Generator
Stars: ✭ 715 (+299.44%)
Mutual labels:  eloquent, database, laravel
Laravel Optimistic Locking
Adds optimistic locking feature to eloquent models.
Stars: ✭ 71 (-60.34%)
Mutual labels:  eloquent, database, laravel
Laravel Tags
Add tags and taggable behaviour to your Laravel app
Stars: ✭ 1,026 (+473.18%)
Mutual labels:  eloquent, database, laravel
Laravel Settings
Store key value pair in database as settings
Stars: ✭ 107 (-40.22%)
Mutual labels:  eloquent, database, laravel
Laravel Scout Postgres
PostgreSQL Full Text Search Engine for Laravel Scout
Stars: ✭ 140 (-21.79%)
Mutual labels:  database, laravel
Config
Manage Laravel configuration by persistent storage
Stars: ✭ 139 (-22.35%)
Mutual labels:  database, laravel
Artisan Menu
📝 Artisan Menu - Use Artisan via an elegant console GUI
Stars: ✭ 141 (-21.23%)
Mutual labels:  laravel, artisan
Laravel Deletable
👾 Gracefully restrict deletion of Laravel Eloquent models
Stars: ✭ 137 (-23.46%)
Mutual labels:  eloquent, laravel
Laravel Db Profiler
Database Profiler for Laravel Web and Console Applications.
Stars: ✭ 141 (-21.23%)
Mutual labels:  database, laravel
Laravel Model Expires
A package to assign expiration dates to Eloquent models.
Stars: ✭ 148 (-17.32%)
Mutual labels:  eloquent, laravel
Pinatra
A PHP copy of Sinatra: a DSL for quickly creating web applications in PHP with minimal effort.
Stars: ✭ 151 (-15.64%)
Mutual labels:  eloquent, laravel

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

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

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.

Requirements

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

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

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

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

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

Please see CHANGELOG for more information what has changed recently.

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

Please see CONTRIBUTING for details.

Security

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

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.

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.

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].