From cf9071c11b237579b4f44de69dd688a3fcdd94b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Falc=C3=B3n?= Date: Wed, 4 Mar 2026 12:06:38 +0000 Subject: [PATCH] fix(migration): make add_waitlist_columns migration idempotent (#200) ## Summary - The `2026_03_04_085843_add_waitlist_columns_to_user_leads_table` migration was failing on deploy because the `position`, `referral_code`, and `referred_by_id` columns already existed in the production database. - Wrapped each column addition with a `Schema::hasColumn()` guard so the migration skips columns that already exist, making it safe to run regardless of the current schema state. --- ...3_add_waitlist_columns_to_user_leads_table.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/database/migrations/2026_03_04_085843_add_waitlist_columns_to_user_leads_table.php b/database/migrations/2026_03_04_085843_add_waitlist_columns_to_user_leads_table.php index cb27503c..97cd5b21 100644 --- a/database/migrations/2026_03_04_085843_add_waitlist_columns_to_user_leads_table.php +++ b/database/migrations/2026_03_04_085843_add_waitlist_columns_to_user_leads_table.php @@ -12,11 +12,18 @@ return new class extends Migration public function up(): void { Schema::table('user_leads', function (Blueprint $table) { - $table->unsignedInteger('position')->after('email'); - $table->string('referral_code', 12)->unique()->after('position'); - $table->char('referred_by_id', 36)->nullable()->after('referral_code'); + if (! Schema::hasColumn('user_leads', 'position')) { + $table->unsignedInteger('position')->after('email'); + } - $table->foreign('referred_by_id')->references('id')->on('user_leads')->nullOnDelete(); + if (! Schema::hasColumn('user_leads', 'referral_code')) { + $table->string('referral_code', 12)->unique()->after('position'); + } + + if (! Schema::hasColumn('user_leads', 'referred_by_id')) { + $table->char('referred_by_id', 36)->nullable()->after('referral_code'); + $table->foreign('referred_by_id')->references('id')->on('user_leads')->nullOnDelete(); + } }); }