Include `dragon-code/laravel-migration-actions` in readme
Opened this issue · 1 comments
I just found out about the dragon-code/laravel-migration-actions package. I think this would work perfectly with the dotenv manager. We should add an example in the readme to show how to use the dotenv migration pattern in a migration action and recommend the package in our composer.json
. Maybe @andrey-helldar could help with that?
@markwalet, why not 🙂
Install the package:
composer require dragon-code/laravel-migration-actions
Create an action file:
php artisan make:migration my_change
// for exemple:
// database/actions/2021_12_23_030847_my_change.php
Add the necessary processing to the created file:
use DragonCode\LaravelActions\Support\Actionable;
use Illuminate\Support\Facades\Artisan;
use MarkWalet\DotenvManager\DotenvManager;
class MyChange extends Actionable
{
protected DotenvManager $dotenv;
public function __constructor(DotenvManager $dotenv)
{
$this->dotenv= $dotenv;
}
public function up(): void
{
$this->dotenv->add('FOO', 'Bar')->after('EXISTING_KEY');
$this->dotenv->update('EXISTING_KEY', 'updatedValue');
}
public function down(): void
{
$this->dotenv->delete('FOO');
$this->dotenv->update('EXISTING_KEY', 'prevValue');
}
protected function success(): void
{
$this->artisan('optimize');
$this->artisan('queue:restart');
}
}
PS: You used the correct title for the text, but the old link - https://packagist.org/packages/dragon-code/laravel-actions instead of https://packagist.org/packages/dragon-code/laravel-migration-actions 🙂
I recently renamed the project from dragon-code/laravel-actions
to dragon-code/laravel-migration-actions
as the name is more obvious and not to be confused with lorisleiva/laravel-actions
, which provides completely different functionality.