I am trying to reference the 'title' column of questions_solutions_language table to the 'title' column of questions table but i am not able to do so
My questions_solutions_language migration
public function up()
{
Schema::create('questions_solutions_language', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('language');
$table->text('solution');
$table->timestamps();
});
Schema::table('questions_solutions_language', function($table)
{
$table->foreign('title')
->references('title')->on('questions')
->onDelete('cascade');
});
}
My Questions migration:
$table->id();
$table->string('title');
$table->string('url');
$table->string('category');
$table->string('difficulty');
$table->string('languages')->nullable(true);
$table->timestamps();
I tried referencing the id column of questions_solutions_language to the id column of questions and it works fine. But as soon as i try to reference the string column i get error. I also tried doing the migrations separately still it doesnt work. Any help will be greatly appreciated