আমি লারভেলে বিদেশী কী তৈরি করার চেষ্টা করছি তবে আমি যখন আমার টেবিলটি ব্যবহার artisanকরে নীচের ত্রুটিটি ছুঁড়ে ফেলেছি তখন :
[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL
: alter table `priorities` add constraint priorities_user_id_foreign foreign
key (`user_id`) references `users` (`id`))
আমার মাইগ্রেশন কোডটি হ'ল:
অগ্রাধিকার স্থানান্তর ফাইল
public function up()
{
//
Schema::create('priorities', function($table) {
$table->increments('id', true);
$table->integer('user_id');
$table->foreign('user_id')->references('id')->on('users');
$table->string('priority_name');
$table->smallInteger('rank');
$table->text('class');
$table->timestamps('timecreated');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::drop('priorities');
}
ব্যবহারকারীদের স্থানান্তর ফাইল
public function up()
{
//
Schema::table('users', function($table)
{
$table->create();
$table->increments('id');
$table->string('email');
$table->string('first_name');
$table->string('password');
$table->string('email_code');
$table->string('time_created');
$table->string('ip');
$table->string('confirmed');
$table->string('user_role');
$table->string('salt');
$table->string('last_login');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schemea::drop('users');
}
আমি কী ভুল করেছি সে সম্পর্কে কোনও ধারণা, আমি এখনই এটি পেতে চাই, যেহেতু আমার প্রচুর টেবিল তৈরি করা দরকার যেমন আমি ব্যবহারকারী, ক্লায়েন্ট, প্রকল্প, কার্য, পরিস্থিতি, অগ্রাধিকার, প্রকার, দলসমূহ। আদর্শভাবে আমি টেবিলগুলি তৈরি করতে চাই যা বিদেশী কী, i..e clients_projectএবং project_tasksইত্যাদি সহ এই ডেটা ধারণ করে hold
আশা করি কেউ আমাকে শুরু করতে সহায়তা করতে পারে।
