<?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('manage_feedback', function (Blueprint $table) {
            $table->id();

            // Foreign key references for principal
            $table->unsignedBigInteger('principal_xid');
            $table->foreign('principal_xid')->references('id')->on('iam_principal')->onDelete('cascade');

            // Feedback reaction and comment columns

            $table->unsignedBigInteger('feedback_reaction_xid');
            $table->foreign('feedback_reaction_xid')->references('id')->on('feedback_reaction')->onDelete('cascade');

            $table->longtext('comment')->nullable();
            $table->boolean('is_app_feedback')->default(0);
            $table->boolean('is_restaurant_feedback')->default(0);
            $table->integer('restaurant_id')->nullable();


            // Soft deletes, timestamps, and additional columns
            $table->softDeletes();
            $table->timestamps();
            $table->boolean('is_active')->default(1)->comment('1=Active, 0=Deactive');
            $table->integer('created_by')->nullable();
            $table->integer('modified_by')->nullable();
        });
    }

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