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

finansu v2のテーブル作成 #895

Merged
merged 10 commits into from
Dec 20, 2024
Merged

Conversation

hikahana
Copy link
Collaborator

@hikahana hikahana commented Dec 3, 2024

対応Issue

resolve #0
なし

概要

FInanSu v2のdomain、sqlを作成しました。

画面スクリーンショット等

  • URL
    スクリーンショット

テスト項目

  • drawioとの差異がないか。
  • dbにsqlが追加されているか

備考

foreignkeyってsqlでどう定義するんですか。

@hikahana hikahana marked this pull request as draft December 3, 2024 19:11
@hikahana hikahana self-assigned this Dec 3, 2024
@hikahana hikahana marked this pull request as ready for review December 3, 2024 19:31
@hikahana hikahana changed the title finansu v2のdomain作成 finansu v2のテーブル作成 Dec 3, 2024
@Kubosaka
Copy link
Collaborator

Kubosaka commented Dec 9, 2024

foreignkeyってsqlでどう定義するんですか。

こんな感じでできるかと思います。これまでのFinanSuでは外部キー制約設けてるとこはないと思いますが、せっかくなんでつけときますか
https://qiita.com/BooookStore/items/6e5d248b5dae0669b70f#:~:text=foreign%20key%20user_id_foreign_key%20(user_id)%20references%20USER%20(id)%2C%0A%09foreign%20key%20book_id_foregin_key%20(book_id)%20references%20BOOK%20(id)

mysql/db/bus_statuses.sql Outdated Show resolved Hide resolved
mysql/db/buy_reports.sql Outdated Show resolved Hide resolved
@hikahana hikahana requested a review from Kubosaka December 9, 2024 17:54
Copy link
Collaborator

@Kubosaka Kubosaka left a 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

@hikahana hikahana requested a review from Kubosaka December 15, 2024 07:29
Copy link
Collaborator

@Kubosaka Kubosaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

外部キーの定義前に、カンマ抜けてるので、sql実行されないです!
いくつかコメントしましたが、概ね良さそう
ローカルでテーブル生成されるか確認した方いいかも

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PRIMARY KEY (id)
PRIMARY KEY (id),

カンマがないのでsynstax errorで実行されない🥺

CREATE TABLE festival_items (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
memo VARCHAR(255) NOT NULL,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not nullかな?
よう確認かも
ER図が間違ってるのか

Copy link
Collaborator Author

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/03_financial_records.sql Show resolved Hide resolved
Comment on lines 5 to 6
user_id INT(10) NOT NULL,
group_id INT(10) NOT NULL,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ASK}
外部キーにUNSIGNEDつけたりしてるけど、これにはなくて意図があれば教えて欲しい

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

全然意図なしです。大体つけ忘れです。。。。。

mysql/db/09_payment_receipts.sql Show resolved Hide resolved
mysql/db/10_buy_statuses.sql Show resolved Hide resolved
@hikahana hikahana requested a review from Kubosaka December 17, 2024 18:27
@hikahana hikahana merged commit 6e721d4 into develop Dec 20, 2024
1 check passed
@hikahana hikahana deleted the feat/hikahana/add-v2-table branch December 20, 2024 03:09
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.

2 participants