mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 15:54:03 +00:00
Rolling back & deleting DB events
This commit is contained in:
parent
2839f45196
commit
78c64f0425
4 changed files with 24 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ use Stancl\Tenancy\Concerns\DealsWithMigrations;
|
|||
use Stancl\Tenancy\Concerns\HasATenantsOption;
|
||||
use Stancl\Tenancy\DatabaseManager;
|
||||
use Stancl\Tenancy\Events\DatabaseRolledBack;
|
||||
use Stancl\Tenancy\Events\RollingBackDatabase;
|
||||
|
||||
class Rollback extends RollbackCommand
|
||||
{
|
||||
|
|
@ -59,6 +60,8 @@ class Rollback extends RollbackCommand
|
|||
tenancy()->runForMultiple($this->option('tenants'), function ($tenant) {
|
||||
$this->line("Tenant: {$tenant['id']}");
|
||||
|
||||
event(new RollingBackDatabase($tenant));
|
||||
|
||||
// Rollback
|
||||
parent::handle();
|
||||
|
||||
|
|
|
|||
9
src/Events/DeletingDatabase.php
Normal file
9
src/Events/DeletingDatabase.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Events;
|
||||
|
||||
class DeletingDatabase extends Contracts\TenantEvent
|
||||
{
|
||||
}
|
||||
9
src/Events/RollingBackDatabase.php
Normal file
9
src/Events/RollingBackDatabase.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Events;
|
||||
|
||||
class RollingBackDatabase extends Contracts\TenantEvent
|
||||
{
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ use Illuminate\Queue\InteractsWithQueue;
|
|||
use Illuminate\Queue\SerializesModels;
|
||||
use Stancl\Tenancy\Database\Models\Tenant;
|
||||
use Stancl\Tenancy\Events\DatabaseDeleted;
|
||||
use Stancl\Tenancy\Events\DeletingDatabase;
|
||||
|
||||
class DeleteDatabase implements ShouldQueue
|
||||
{
|
||||
|
|
@ -26,6 +27,8 @@ class DeleteDatabase implements ShouldQueue
|
|||
|
||||
public function handle()
|
||||
{
|
||||
event(new DeletingDatabase($this->tenant));
|
||||
|
||||
$this->tenant->database()->manager()->deleteDatabase($this->tenant);
|
||||
|
||||
event(new DatabaseDeleted($this->tenant));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue