mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-14 07:14:03 +00:00
[2.x] Queued post-creation automigration (#154)
* Queued post-creation automigration * Add shouldQueueMigration() * Automigration test, config key, QueueTenancyBootstrapper support for QueueFake * Apply fixes from StyleCI * Fix if statement
This commit is contained in:
parent
b66574b1ab
commit
abd0b8f04e
7 changed files with 88 additions and 6 deletions
|
|
@ -15,7 +15,10 @@ class QueuedTenantDatabaseCreator implements ShouldQueue
|
|||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var TenantDatabaseManager */
|
||||
protected $databaseManager;
|
||||
|
||||
/** @var string */
|
||||
protected $databaseName;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@ class QueuedTenantDatabaseDeleter implements ShouldQueue
|
|||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var TenantDatabaseManager */
|
||||
protected $databaseManager;
|
||||
|
||||
/** @var string */
|
||||
protected $databaseName;
|
||||
|
||||
/**
|
||||
|
|
|
|||
38
src/Jobs/QueuedTenantDatabaseMigrator.php
Normal file
38
src/Jobs/QueuedTenantDatabaseMigrator.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Stancl\Tenancy\Tenant;
|
||||
|
||||
class QueuedTenantDatabaseMigrator implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var Tenant */
|
||||
protected $tenant;
|
||||
|
||||
public function __construct(Tenant $tenant)
|
||||
{
|
||||
$this->tenant = $tenant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
Artisan::call('tenants:migrate', [
|
||||
'--tenants' => [$this->tenant->id],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue