Package to help refactor data in staging and production environments.
composer require mwi/laravel-refactor
php artisan migrate
If you're on laravel 5.5 or later the service provider will be automatically loaded and you can skip this step, if not, add to your config/app.php
providers
'providers' => [
// ...
MWI\LaravelRefactor\ServiceProvider::class,
// ...
],
Once you have the package setup and migrations ran
php artisan make:refactor convert_relationship_to_many_to_many
Instruct the up and down methods
<?php
class ConvertRelationshipToManyToMany
{
/**
* Run the refactor.
*
* @return void
*/
public function up()
{
//
}
/**
* Reverse the refactor.
*
* @return void
*/
public function down()
{
//
}
}
Run the refactor command
php artisan refactor
You can roll all migrations back
php artisan refactor --rollback
You can also run a certain number of steps
php artisan refactor --steps=2
php artisan refactor --rollback --steps=1