改进 task,增加 notifications

This commit is contained in:
iVampireSP.com 2022-08-13 16:42:23 +08:00
parent c9b4b4dcc1
commit bc85e6c1f0
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
2 changed files with 26 additions and 5 deletions

View File

@ -1,8 +1,10 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use App\Models\User;
use App\Models\Module\ProviderModule;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
@ -15,6 +17,21 @@ public function up()
{
Schema::create('tasks', function (Blueprint $table) {
$table->id();
$table->string('title');
// progress (max 100)
$table->integer('progress')->default(0);
// status
$table->enum('status', ['pending', 'done', 'success', 'failed', 'error', 'cancelled', 'processing'])->index();
// user id
$table->foreignIdFor(User::class)->index();
// provider module id
$table->foreignIdFor(ProviderModule::class)->index();
$table->timestamps();
});
}

View File

@ -13,8 +13,12 @@
*/
public function up()
{
Schema::create('messages', function (Blueprint $table) {
$table->id();
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
@ -26,6 +30,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('messages');
Schema::dropIfExists('notifications');
}
};