After creating the user table schema and the user_type table schema it constantly gives me problems with the foreign key I set the db in utf8 if it can be a problem, I've been hitting my head for hours but I can't get out of it.
Schema::create('users_panel', function (Blueprint $table) {
$table
->id();
$table
->unsignedBigInteger('id_type_user');
$table
->string('company_name');
$table
->string('email')->unique();
$table
->string('password', 60);
$table
->timestamp('email_verified_at')
->nullable();
$table
->string('representative_name')
->nullable();
$table
->string('phone_number')
->nullable();
$table
->string('address');
$table
->rememberToken();
$table
->timestamps();
});
Schema::table('users_panel', function (Blueprint $table) {
$table
->foreign('id_type_user')
->references('id')
->on('type_users')
->onDelete('cascade');
});
type_users:
Schema::create('type_users', function (Blueprint $table) {
$table->id();
$table->string('type_user');
$table->timestamps();
});
error:
PDOException::("SQLSTATE[HY000]: General error: 1005 Can't create table prysma_db.users_panel (errno: 150 "Foreign key constraint is incorrectly formed")")