<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('follows_project', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained()->onDelete('cascade'); // ID pengguna yang mengikuti
            $table->foreignId('followed_user_id')->constrained('users')->onDelete('cascade'); // ID pemilik proyek
            $table->foreignId('project_id')->constrained('permohonan_projects')->onDelete('cascade'); // ID proyek
            $table->string('status'); // Status follow
            $table->timestamps();
        });



        Schema::create('notifications', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->constrained('users')->onDelete('cascade'); // ID penerima notifikasi
            $table->foreignId('follows_project_id')->constrained('follows_project')->onDelete('cascade'); // ID follow yang terkait
            $table->string('message'); // Pesan notifikasi
            $table->boolean('is_read')->default(false); // Status baca notifikasi
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('follows_project');
        Schema::dropIfExists('notifications');
    }
};
