-
Notifications
You must be signed in to change notification settings - Fork 1
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
finansu v2のテーブル作成 #895
finansu v2のテーブル作成 #895
Conversation
こんな感じでできるかと思います。これまでのFinanSuでは外部キー制約設けてるとこはないと思いますが、せっかくなんでつけときますか |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
言い忘れたけど、tableが作成されてないとforeign keyとインデックス貼れないから、docker-entrypoint-initdb.dで実行されるsqlのファイル順番指定してあげたほうがいいかも
ex) 〇〇.sql → 01_〇〇.sql
今のままだと、sql全部実行されないです
ERROR 1064 (42000) at line 3: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOREIGN KEY festival_item_id_foreign_key (festival_item_id) REFERENCES festival_' at line 10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
外部キーの定義前に、カンマ抜けてるので、sql実行されないです!
いくつかコメントしましたが、概ね良さそう
ローカルでテーブル生成されるか確認した方いいかも
mysql/db/03_financial_records.sql
Outdated
year_id INT(10) UNSIGNED NOT NULL, | ||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
PRIMARY KEY (id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PRIMARY KEY (id) | |
PRIMARY KEY (id), |
カンマがないのでsynstax errorで実行されない🥺
mysql/db/05_festival_items.sql
Outdated
CREATE TABLE festival_items ( | ||
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, | ||
name VARCHAR(255) NOT NULL, | ||
memo VARCHAR(255) NOT NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not nullかな?
よう確認かも
ER図が間違ってるのか
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あ、ER図コピペで作ってたからnot nullにしてました。。。
mysql/db/07_user_groups.sql
Outdated
user_id INT(10) NOT NULL, | ||
group_id INT(10) NOT NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[ASK}
外部キーにUNSIGNEDつけたりしてるけど、これにはなくて意図があれば教えて欲しい
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
全然意図なしです。大体つけ忘れです。。。。。
対応Issue
resolve #0
なし
概要
FInanSu v2のdomain、sqlを作成しました。
画面スクリーンショット等
URL
スクリーンショット
テスト項目
備考
foreignkeyってsqlでどう定義するんですか。