<?php

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

return new class extends Migration {
    public function up(): void
    {
        Schema::create('transactions', function (Blueprint $table) {
            $table->id();

            $table->string('trx_id')->unique();
            $table->string('ref_id')->nullable();
            $table->foreignId('user_id')->constrained()->cascadeOnDelete();

            $table->string('code_product');
            $table->string('target_id');
            $table->bigInteger('price');
            $table->bigInteger('profit');
            $table->bigInteger('total_price');
            $table->text('message')->nullable();
            $table->enum('trx_status', ['Sukses', 'Pending', 'Gagal'])->default('Pending');
            $table->string('sn')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('transactions');
    }
};
