dostogir
6 months ago
1178
4
Laravel

` (errno: 150 "Foreign key constraint is incorrectly formed") posts_comment_id_foreign` foreign key (`comment_id`) references `comments` (`id`)

Posted 6 months ago by dostogir

public function up() { Schema::create('posts', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('title'); $table->string('image')->default('default.png'); $table->text('description'); $table->text('solution'); $table->unsignedBigInteger('user_id'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->unsignedBigInteger('language_id'); $table->foreign('language_id')->references('id')->on('languages'); $table->unsignedBigInteger('comment_id'); $table->foreign('comment_id')->references('id')->on('comments')->onDelete('cascade'); $table->timestamps(); }); }

Please sign in or create an account to participate in this conversation.