Skip to content

[Fix] sponsorship_activities マイグレーションの型不一致を修正#1055

Merged
Wakai111 merged 3 commits intodevelopfrom
fix/migration-foreign-key-type
Feb 27, 2026
Merged

[Fix] sponsorship_activities マイグレーションの型不一致を修正#1055
Wakai111 merged 3 commits intodevelopfrom
fix/migration-foreign-key-type

Conversation

@TkymHrt
Copy link
Member

@TkymHrt TkymHrt commented Feb 21, 2026

対応Issue

resolve #0

概要

  • 参照先のテーブル(sponsors, users, sponsor_styles 等)の主キーが INT UNSIGNED で定義されているのに対して、マイグレーションファイルでは INT で定義されていたため、カラムの型を INT から INT UNSIGNED に変更しました。

  • 外部キー制約を追加

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

  • URL
    スクリーンショット

テスト項目

  • make del-db でボリュームを削除した状態から make run-all が正常に完走することを確認。
  • マイグレーションログで create_sponsorship_activities が成功していることを確認。

備考

関連: #1048

@github-actions github-actions bot added the bug Something isn't working label Feb 21, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @TkymHrt, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

このプルリクエストは、データベースのスキーマにおける型不一致の問題を解決します。sponsorship_activities および activity_sponsor_style_links テーブル内の外部キーとして機能するカラムが、参照先のテーブル(sponsors, users, sponsor_styles など)の主キーが INT UNSIGNED であるにもかかわらず、INT として定義されていました。この変更により、これらのカラムが INT UNSIGNED に更新され、データベース全体のデータ整合性と一貫性が確保されます。

Highlights

  • マイグレーションファイルにおける型不一致の修正: データベースの整合性を保つため、sponsorship_activities および activity_sponsor_style_links テーブルの関連カラムの型を INT から INT UNSIGNED に変更しました。これにより、参照先のテーブルの主キー型との不一致が解消されます。
Changelog
  • mysql/migrations/000003_create_sponsorship_activities.up.sql
    • sponsorship_activities テーブルの id, year_periods_id, sponsor_id, user_id カラムの型を INT UNSIGNED に変更しました。
    • activity_sponsor_style_links テーブルの id, sponsorship_activity_id, sponsor_style_id カラムの型を INT UNSIGNED に変更しました。
Activity
  • 現在、このプルリクエストに関するレビューコメントや進捗などのアクティビティはありません。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

このプルリクエストは、sponsorship_activities関連のマイグレーションにおけるカラムの型をINTからINT UNSIGNEDに修正するもので、参照先テーブルの型と一致させるための重要な修正です。変更内容は正しい方向性ですが、いくつか改善点があります。
第一に、データの整合性を保証するために、マイグレーションファイルに外部キー制約を追加することを強く推奨します。リポジトリ内の他のマイグレーションファイルでは外部キーが定義されており、それに倣うべきです。
第二に、データベースの型がINT UNSIGNEDに変更されたにもかかわらず、関連するGoのドメインモデルでは符号付きのint型が使用され続けています。IDが2,147,483,647を超えた場合にオーバーフローを引き起こす可能性があるため、Goの型もuintなどに更新することをお勧めします。この点は変更範囲外のファイルに関する指摘のため、全体コメントにて失礼します。

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 21, 2026

Deploying finansu with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3f11d94
Status: ✅  Deploy successful!
Preview URL: https://77f021cc.finansu.pages.dev
Branch Preview URL: https://fix-migration-foreign-key-ty.finansu.pages.dev

View logs

@TkymHrt TkymHrt requested review from Wakai111 and hikahana February 21, 2026 14:45
@Wakai111
Copy link
Collaborator

型合わせ助かります。
マージします。

@Wakai111 Wakai111 merged commit 7cbbe97 into develop Feb 27, 2026
3 checks passed
@Wakai111 Wakai111 deleted the fix/migration-foreign-key-type branch February 27, 2026 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants