Files
citrus-cms/database/migrations/2025_10_31_142134_create_notifications_table.php
T
2026-04-28 21:15:09 +03:00

46 lines
1.2 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateNotificationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->string('notification_code');
$table->string('title');
$table->text('message');
$table->string('link')->nullable();
$table->boolean('is_read')->default(false);
$table->timestamps();
// Foreign key constraint
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
// Indexes for better performance
$table->index(['user_id', 'is_read']);
$table->index('notification_code');
$table->index('created_at');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('notifications');
}
}