From eca97466b8e3e18fd59d3457b78a5c939b5efb4e Mon Sep 17 00:00:00 2001 From: Snider Date: Wed, 28 Jan 2026 17:23:48 +0000 Subject: [PATCH] fix: remove FK constraints to non-existent orders/refunds tables Credit notes can exist independently of orders. Foreign keys will be added when orders and refunds modules are implemented. Co-Authored-By: Claude Opus 4.5 --- Migrations/0001_01_01_000002_create_credit_notes_table.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Migrations/0001_01_01_000002_create_credit_notes_table.php b/Migrations/0001_01_01_000002_create_credit_notes_table.php index f0823e7..6876134 100644 --- a/Migrations/0001_01_01_000002_create_credit_notes_table.php +++ b/Migrations/0001_01_01_000002_create_credit_notes_table.php @@ -24,8 +24,9 @@ return new class extends Migration $table->foreignId('user_id')->constrained('users')->cascadeOnDelete(); // Source references (optional - not all credits come from orders/refunds) - $table->foreignId('order_id')->nullable()->constrained('orders')->nullOnDelete(); - $table->foreignId('refund_id')->nullable()->constrained('refunds')->nullOnDelete(); + // Foreign keys added when orders/refunds tables exist + $table->unsignedBigInteger('order_id')->nullable(); + $table->unsignedBigInteger('refund_id')->nullable(); // Credit details $table->string('reference_number', 32)->unique(); @@ -39,7 +40,7 @@ return new class extends Migration // Tracking $table->decimal('amount_used', 10, 2)->default(0); - $table->foreignId('applied_to_order_id')->nullable()->constrained('orders')->nullOnDelete(); + $table->unsignedBigInteger('applied_to_order_id')->nullable(); $table->timestamp('issued_at')->nullable(); $table->timestamp('applied_at')->nullable(); $table->timestamp('voided_at')->nullable();