36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
Schema::create('notifications', function (Blueprint $table) {
|
|
$table->uuid('id')->primary();
|
|
$table->uuid('user_id')->nullable();
|
|
$table->uuid('workspace_id');
|
|
$table->string('type');
|
|
$table->string('channel');
|
|
$table->string('title');
|
|
$table->text('body');
|
|
$table->json('data')->nullable();
|
|
$table->timestamp('read_at')->nullable();
|
|
$table->timestamp('archived_at')->nullable();
|
|
$table->timestamps();
|
|
|
|
$table->foreign('user_id')->references('id')->on('users')->nullOnDelete();
|
|
$table->foreign('workspace_id')->references('id')->on('workspaces')->cascadeOnDelete();
|
|
$table->index(['user_id', 'workspace_id', 'read_at']);
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('notifications');
|
|
}
|
|
};
|