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 <noreply@anthropic.com>
This commit is contained in:
Snider 2026-01-28 19:46:15 +00:00
parent eca97466b8
commit 9113cede8a

View file

@ -63,15 +63,14 @@ return new class extends Migration
// Billing status // Billing status
$table->boolean('billed')->default(false); $table->boolean('billed')->default(false);
$table->foreignId('invoice_item_id')->nullable() $table->unsignedBigInteger('invoice_item_id')->nullable();
->constrained('invoice_items')->nullOnDelete();
$table->json('metadata')->nullable(); $table->json('metadata')->nullable();
$table->timestamps(); $table->timestamps();
$table->unique(['subscription_id', 'meter_id', 'period_start'], 'sub_meter_period_unique'); $table->unique(['subscription_id', 'meter_id', 'period_start'], 'sub_meter_period_unique');
$table->index(['subscription_id', 'period_start', 'period_end']); $table->index(['subscription_id', 'period_start', 'period_end'], 'sub_usage_period_idx');
$table->index(['billed', 'period_end']); $table->index(['billed', 'period_end'], 'sub_usage_billed_idx');
// Add foreign key if subscriptions table exists // Add foreign key if subscriptions table exists
if (Schema::hasTable('subscriptions')) { if (Schema::hasTable('subscriptions')) {