<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('transactions', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id');
            $table->string('tx_id');
            $table->string('type'); // deposit or withdrawal, or transfer
            $table->string('category'); //bank, local-transfer, wire-transfer, crypto
            $table->string('bank_name');//bank name, coin name
            $table->string('receiver_name');//receiver name
            $table->string('receiver_account');//receiver account, btc wallet
            $table->string('remark'); //description of transaction
            $table->decimal('amount', 19, 4); //amount of transaction
            $table->string('status')->default(PENDING_TX);
            $table->text('reason')->nullable();
            $table->timestamps();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        });
    }

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