DataGrip is creating index instead of foreign key


Hello. I have a problem. DataGrip creates index instead of foreign key. When I type:

alter table UrzWkl
add constraint UrzWkl_Urzadzenie_ID_Urzadzenia_fk
foreign key (ID_Urzadzenia) references Urzadzenie (ID_Urzadzenia);

 then the program creates the index. The index itself has the following code.

-- auto-generated definition
create index UrzWkl_Urzadzenie_ID_Urzadzenia_fk
on UrzWkl (ID_Urzadzenia);

I have no idea what i'm doing wrong. Thank you in advance for your help.

Here is video description of my problem:

Comment actions Permalink


Could you specify DataGrip version, MySQL server version you are on, engine and DDL for tables?

When I was trying to reproduce the issue I got:

12:18 alter table table_name
add constraint table_name_table_name_2_for_foreign_key_fk
foreign key (column_1) references table_name_2 (for_foreign_key)

12:18 [HY000][150] Create table 'guest/#sql-1_7' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns.


That led me to the stack overflow discussion.

Comment actions Permalink

Any news here?



Please sign in to leave a comment.