Я запускаю сообщение об ошибке ниже после определения моего механизма таблицы базы данных для innoDB . Я попробовал все там, но это не работает. Как вы можете сказать, я использую bigInteger
и unsignedBigInteger
для своего типа столбца.
Ошибка
Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table
users add constraint
users_account_status_id_foreign foreign key (
account_status_id ) references
статусы (
id ) on delete set null on update cascade)
************ USERS TABLE ***************************
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('first_name');
$table->string('last_name');
$table->string('email')->unique();
$table->string('phone')->nullable();
$table->string('user_code')->unique();
$table->integer('online_status')->boolean()->default(0);
$table->unsignedBigInteger('account_status_id')->default(0);
$table->string('image')->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
$table->softDeletes();
$table->foreign('account_status_id')->references('id')->on('statuses')->onUpdate('cascade')->onDelete('set null');
});
*********STATUSES TABLE *******************
Schema::create('statuses', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name')->unique();
$table->string('slug')->unique();
$table->timestamps();
// $table->engine = 'InnoDB';
});
******* CONFIG/database.php ****************
'mysql' => [
'driver' => 'mysql',
...
'engine' => 'innoDB',
...
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],