<?php

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

class CreatePaymentTimeoutsTable extends Migration
{
    /**
     * 运行迁移
     *
     * @return void
     */
    public function up()
    {
        Schema::create('payment_timeouts', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('payment_record_id')->comment('支付记录ID');
            $table->integer('timeout_minutes')->default(30)->comment('超时时间(分钟)');
            $table->timestamp('processed_at')->comment('处理时间');
            $table->timestamps();

            $table->foreign('payment_record_id')->references('id')->on('payment_records')->onDelete('cascade');
        });
    }

    /**
     * 回滚迁移
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('payment_timeouts');
    }
}
