<?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('iam_principal_otp', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('principal_xid');
            $table->foreign('principal_xid')->references('id')->on('iam_principal')->onDelete('cascade');
            $table->string('otp_code');
            $table->string('otp_purpose');
            $table->dateTime('valid_till');
            $table->boolean('is_used')->default(0);
            $table->smallInteger('active')->default(1);
            $table->integer('created_by')->nullable();
            $table->timestamp('created_on')->nullable();
            $table->integer('modified_by')->nullable();
            $table->timestamp('modified_on')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

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