LoginSignup
1
0

More than 3 years have passed since last update.

あれ?foreign keyがつかない。。

Posted at
mysql>     alter table student_course
    ->        add constraint FKq7yw2wg9wlt2cnj480hcdn6dq
    ->        foreign key (student_id)
    ->        references student (id);
 show create table student_course;

| student_course | CREATE TABLE `student_course` (
  `student_id` bigint(20) NOT NULL,
  `course_id` bigint(20) NOT NULL,
  KEY `FKejrkh4gv8iqgmspsanaji90ws` (`course_id`),
  KEY `FKq7yw2wg9wlt2cnj480hcdn6dq` (`student_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 |

原因 > ストレージエンジンがMySAMになってた

MySAMだとforeign keyがつかないのでInnoDBにする

spring bootの設定

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0