Teren-app/database/migrations/2025_10_02_120000_create_payments_table.php
2025-10-02 18:35:02 +02:00

35 lines
1.1 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
{
if (! Schema::hasTable('payments')) {
Schema::create('payments', function (Blueprint $table): void {
$table->id();
$table->foreignId('account_id')->constrained()->cascadeOnDelete();
$table->bigInteger('amount_cents');
$table->string('currency', 3)->default('EUR');
$table->string('reference')->nullable();
$table->timestamp('paid_at')->nullable();
$table->jsonb('meta')->nullable();
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
$table->softDeletes();
$table->index(['account_id', 'paid_at']);
$table->index('reference');
});
}
}
public function down(): void
{
Schema::dropIfExists('payments');
}
};