SQLSTATE[HY000]: General error: 1005 Can't create table ``.`labels` (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table `labels` add constraint
// To solve that first try to migrate another table.
SQLSTATE[HY000]: General error: 1005 Can't create table ``.`labels` (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table `labels` add constraint
// To solve that first try to migrate another table.
sqlstate[hy000]: general error: 1005 can't create table (errno: 150 "foreign key constraint is incorrectly formed")
-- make sure your [foreign key] column and [referenced] column same type or length.
-- look like this:-
create table users(
id INT(11) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
fullname VARCHAR(30) NOT NULL
);
create table user_addr(
id INT PRIMARY KEY AUTO_INCREMENT,
user_id INT(11) UNSIGNED NOT NULL,
addr VARCHAR(150) NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id)
);
-- [ user table: id->int(11) unsigned ]-
-- |--> same data type with length
-- [ user_addr table: user_id->int(11) unsigned ]-
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us