Framework: SQLSTATE[HY000]: General error: 1005 Can't create table `vanila`.`#sql-1d4a_1e`

Created on 11 Jun 2019  路  5Comments  路  Source: laravel/framework

Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1005 Can't create table vanila.#sql-1d4a_1e (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table profiles add constraint profiles_user_id_foreign foreign key (user_id) references users (id))

Most helpful comment

It may be that the users.id and theprofiles.user_id don't have the same data type, e.g. int vs. bigint.

All 5 comments

PLZ Help

It may be that the users.id and theprofiles.user_id don't have the same data type, e.g. int vs. bigint.

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'json not null, custom_properties json not null, responsive_images json not n' at line 1 (SQL: create table media (id bigint unsigned not null auto_increment primary key, model_type varchar(191) not null, model_id bigint unsigned not null, collection_name varchar(191) not null, name varchar(191) not null, file_name varchar(191) not null, mime_type varchar(191) null, disk varchar(191) not null, size int unsigned not null, manipulations json not null, custom_properties json not null, responsive_images json not null, order_column int unsigned null, created_at timestamp null, updated_at timestamp null) default character set utf8 collate 'utf8_unicode_ci')

It may be that the users.id and theprofiles.user_id don't have the same data type, e.g. int vs. bigint.

Thank @mfn

Try using $table->id() instead of $table->increament('is') in your migrations

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iivanov2 picture iivanov2  路  3Comments

fideloper picture fideloper  路  3Comments

ghost picture ghost  路  3Comments

SachinAgarwal1337 picture SachinAgarwal1337  路  3Comments

JamborJan picture JamborJan  路  3Comments