From 6d83c32114fdd9c17664117f2f72d03a36271f24 Mon Sep 17 00:00:00 2001 From: Snider Date: Wed, 22 Apr 2026 21:34:57 +0100 Subject: [PATCH] fix(referral): drop FKs to nonexistent 'orders' + 'invoices' tables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The referral_commissions migration FK-referenced 'orders' and 'invoices' tables, but neither is ever created by any migration in the codebase. MariaDB silently accepted the FKs (checks disabled during migration), Postgres rejects strictly. Changed both columns to plain nullable unsignedBigInteger — same column shape, no FK constraint. Data still references orders/invoices by id via application logic. Proper FKs can be added in a follow-up migration once orders/invoices migrations land. Co-Authored-By: Virgil --- ...026_01_26_000001_create_referral_tables.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Migrations/2026_01_26_000001_create_referral_tables.php b/Migrations/2026_01_26_000001_create_referral_tables.php index 32cea49..3e1fb47 100644 --- a/Migrations/2026_01_26_000001_create_referral_tables.php +++ b/Migrations/2026_01_26_000001_create_referral_tables.php @@ -136,15 +136,15 @@ return new class extends Migration ->constrained('users') ->cascadeOnDelete(); - $table->foreignId('order_id') - ->nullable() - ->constrained('orders') - ->nullOnDelete(); - - $table->foreignId('invoice_id') - ->nullable() - ->constrained('invoices') - ->nullOnDelete(); + // NOTE: `orders` and `invoices` tables are not created by any + // migration in the current codebase. MariaDB silently accepted + // FKs to nonexistent tables (FK checks disabled during the + // migration), but Postgres rejects them. Keeping the columns + // as plain nullable bigint so the schema deploys on both DBs; + // FK constraints can be added in a follow-up migration once + // the orders/invoices tables actually exist. + $table->unsignedBigInteger('order_id')->nullable(); + $table->unsignedBigInteger('invoice_id')->nullable(); // Commission calculation $table->decimal('order_amount', 10, 2); // Net order amount (after tax/discounts)