From 9113cede8aec9d19d172b529dbf686fbeec76845 Mon Sep 17 00:00:00 2001 From: Snider Date: Wed, 28 Jan 2026 19:46:15 +0000 Subject: [PATCH] fix: remove FK to non-existent invoice_items, shorten index names - Remove FK constraint to invoice_items table (not yet created) - Shorten index names to avoid MariaDB 64-char limit Co-Authored-By: Claude Opus 4.5 --- .../2026_01_26_000000_create_usage_billing_tables.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Migrations/2026_01_26_000000_create_usage_billing_tables.php b/Migrations/2026_01_26_000000_create_usage_billing_tables.php index 6fcc55f..a9a10b3 100644 --- a/Migrations/2026_01_26_000000_create_usage_billing_tables.php +++ b/Migrations/2026_01_26_000000_create_usage_billing_tables.php @@ -63,15 +63,14 @@ return new class extends Migration // Billing status $table->boolean('billed')->default(false); - $table->foreignId('invoice_item_id')->nullable() - ->constrained('invoice_items')->nullOnDelete(); + $table->unsignedBigInteger('invoice_item_id')->nullable(); $table->json('metadata')->nullable(); $table->timestamps(); $table->unique(['subscription_id', 'meter_id', 'period_start'], 'sub_meter_period_unique'); - $table->index(['subscription_id', 'period_start', 'period_end']); - $table->index(['billed', 'period_end']); + $table->index(['subscription_id', 'period_start', 'period_end'], 'sub_usage_period_idx'); + $table->index(['billed', 'period_end'], 'sub_usage_billed_idx'); // Add foreign key if subscriptions table exists if (Schema::hasTable('subscriptions')) {