<?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('multibanco_references', function (Blueprint $table) {
$table->id();
$table->foreignId('vcard_id')->constrained('vcards')->onDelete('cascade');
$table->string('order_id', 100)->unique();
$table->string('entity', 10)->comment('IfthenPay entity number (e.g. 11249)');
$table->string('reference', 9)->comment('9-digit Multibanco reference');
$table->decimal('amount', 8, 2);
$table->enum('status', ['pending', 'paid', 'expired', 'cancelled'])->default('pending');
$table->timestamp('expires_at')->nullable();
$table->timestamp('paid_at')->nullable();
$table->timestamps();
$table->index(['entity', 'reference']);
$table->index(['vcard_id', 'status']);
});
}
public function down(): void
{
Schema::dropIfExists('multibanco_references');
}
};
|