Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team d #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Team d #9

wants to merge 3 commits into from

Conversation

hamasugar
Copy link

No description provided.

@hamasugar
Copy link
Author

    -> ;
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level   | Code | Message                                                                                                                                                                       |
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Warning |  150 | Create table 'treasurenavi/exchange' with foreign key constraint failed. There is no index in the referenced table where the referenced columns appear as the first columns.
 |
| Error   | 1215 | Cannot add foreign key constraint                                                                                                                                             |
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)```

@dkkoma
Copy link
Contributor

dkkoma commented Sep 18, 2018

foreign keyを貼られる側のテーブルのキーと貼る側のテーブルでキーの書く順番をあわせないといけなかったようです

FOREIGN KEY(member_id, service) REFERENCES other_users(member_id, service) とすればいけたそうです。

@hamasugar
Copy link
Author

hamasugar commented Sep 18, 2018 via email

@proshunsuke
Copy link
Contributor

この辺ですかね
https://dev.mysql.com/doc/refman/5.7/en/create-table-foreign-keys.html

InnoDB permits a foreign key to reference any column or group of columns. However, in the referenced table, there must be an index where the referenced columns are listed as the first columns in the same order. 

InnoDBの場合は順番を守らないといけないみたいです

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants