<?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('redeem_restaurant', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('iam_principal_xid');
            $table->foreign('iam_principal_xid')->references('id')->on('iam_principal')->onDelete('cascade');
            $table->unsignedBigInteger('manage_restaurants_xid');
            $table->foreign('manage_restaurants_xid')->references('id')->on('manage_restaurants')->onDelete('cascade');
            $table->boolean('is_active')->default(1)->comment('1=Active, 0=Expired');
            $table->boolean('is_redeem')->default(0)->comment('1=Redeem, 0=Not Redeem');
            $table->integer('count')->default(0);
            $table->timestamp('redeem_date')->nullable();
            $table->boolean('is_redeemption_undone')->default(0);
            $table->timestamp('redeemption_undone_date')->nullable();
            $table->integer('created_by')->nullable();
            $table->integer('modified_by')->nullable();
            $table->softDeletes();
            $table->timestamps();
        });
    }

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