From a2aa74aa8a9448632f178fcf6822537cda8c44ac Mon Sep 17 00:00:00 2001 From: Darko Gjorgjijoski <5760249+gdarko@users.noreply.github.com> Date: Fri, 12 Jun 2026 15:19:21 +0200 Subject: [PATCH] fix(migrations): align ai_conversations company_id/user_id with INT pk (#683) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to #618. The ai_conversations table (added after #618) used foreignId() (BIGINT) for company_id/user_id, which mismatches the INT UNSIGNED users.id / companies.id and breaks MySQL FK creation (error 3780) on the v2->v3 upgrade. Use plain unsignedInteger, matching the codebase's no-DB-FK convention for these columns. conversation_id stays foreignId — it references the BIGINT ai_conversations.id and its delete cascade is intentional (and covered by AiChatFlowTest). --- ..._11_154445_create_ai_conversations_and_messages_tables.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/migrations/2026_04_11_154445_create_ai_conversations_and_messages_tables.php b/database/migrations/2026_04_11_154445_create_ai_conversations_and_messages_tables.php index 0eb12b1e..75c9267f 100644 --- a/database/migrations/2026_04_11_154445_create_ai_conversations_and_messages_tables.php +++ b/database/migrations/2026_04_11_154445_create_ai_conversations_and_messages_tables.php @@ -10,8 +10,8 @@ return new class extends Migration { Schema::create('ai_conversations', function (Blueprint $table) { $table->id(); - $table->foreignId('company_id')->constrained()->cascadeOnDelete(); - $table->foreignId('user_id')->constrained()->cascadeOnDelete(); + $table->unsignedInteger('company_id'); + $table->unsignedInteger('user_id'); $table->string('title')->nullable(); $table->string('model', 100)->nullable(); $table->timestamps();