39 lines
1.5 KiB
PHP
39 lines
1.5 KiB
PHP
<?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('external_payments', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('tenant_id')->constrained()->restrictOnDelete();
|
|
$table->foreignId('invoice_id')->constrained()->restrictOnDelete();
|
|
$table->foreignId('supplier_bank_detail_id')->constrained()->restrictOnDelete();
|
|
$table->foreignId('created_by')->constrained('users')->restrictOnDelete();
|
|
$table->foreignId('reviewed_by')->nullable()->constrained('users')->restrictOnDelete();
|
|
$table->string('status')->default('pending');
|
|
$table->bigInteger('amount_minor');
|
|
$table->string('currency', 3);
|
|
$table->date('paid_on');
|
|
$table->text('external_reference');
|
|
$table->string('reference_hash', 64);
|
|
$table->string('payload_hash', 64);
|
|
$table->text('evidence_reference');
|
|
$table->text('bank_snapshot');
|
|
$table->text('review_reason')->nullable();
|
|
$table->timestamp('reviewed_at')->nullable();
|
|
$table->timestamps();
|
|
$table->unique(['tenant_id', 'reference_hash']);
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
throw new LogicException('Preservar registos e conferências de pagamentos externos.');
|
|
}
|
|
};
|