diff --git a/web/app/Console/Commands/CreateDailyFullHostingSubscriptionsBackup.php b/web/app/Console/Commands/CreateDailyFullHostingSubscriptionsBackup.php index c515f6d..8e5a2fa 100644 --- a/web/app/Console/Commands/CreateDailyFullHostingSubscriptionsBackup.php +++ b/web/app/Console/Commands/CreateDailyFullHostingSubscriptionsBackup.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use App\Jobs\ProcessHostingSubscriptionBackup; use App\Models\Backup; use App\Models\HostingSubscription; use App\Models\HostingSubscriptionBackup; @@ -45,10 +46,8 @@ class CreateDailyFullHostingSubscriptionsBackup extends Command ->where('created_at', '>=', Carbon::now()->subHours(24)) ->first(); if (! $findBackup) { - $backup = new HostingSubscriptionBackup(); - $backup->hosting_subscription_id = $hostingSubscription->id; - $backup->backup_type = 'full'; - $backup->save(); + + ProcessHostingSubscriptionBackup::dispatch($hostingSubscription->id); } else { $this->error('Backup already exists for ' . $hostingSubscription->domain); diff --git a/web/app/Jobs/ProcessHostingSubscriptionBackup.php b/web/app/Jobs/ProcessHostingSubscriptionBackup.php new file mode 100644 index 0000000..be2dcb2 --- /dev/null +++ b/web/app/Jobs/ProcessHostingSubscriptionBackup.php @@ -0,0 +1,40 @@ +hostingSubscriptionId = $hostingSubscriptionId; + } + + /** + * Execute the job. + */ + public function handle(): void + { + echo "Backing up hosting subscription with ID: {$this->hostingSubscriptionId}\n"; + + sleep(3); +// +// $backup = new HostingSubscriptionBackup(); +// $backup->hosting_subscription_id = $this->hostingSubscriptionId; +// $backup->backup_type = 'full'; +// $backup->save(); + } +} diff --git a/web/config/queue.php b/web/config/queue.php index 01c6b05..50bf070 100644 --- a/web/config/queue.php +++ b/web/config/queue.php @@ -13,7 +13,7 @@ return [ | */ - 'default' => env('QUEUE_CONNECTION', 'sync'), + 'default' => 'database', /* |-------------------------------------------------------------------------- diff --git a/web/database/migrations/2024_05_07_120402_create_jobs_table.php b/web/database/migrations/2024_05_07_120402_create_jobs_table.php new file mode 100644 index 0000000..6098d9b --- /dev/null +++ b/web/database/migrations/2024_05_07_120402_create_jobs_table.php @@ -0,0 +1,32 @@ +bigIncrements('id'); + $table->string('queue')->index(); + $table->longText('payload'); + $table->unsignedTinyInteger('attempts'); + $table->unsignedInteger('reserved_at')->nullable(); + $table->unsignedInteger('available_at'); + $table->unsignedInteger('created_at'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('jobs'); + } +};