Skip to content

スキーマ変更に対応#31

Merged
kantacky merged 7 commits intomainfrom
update-spec
Feb 5, 2026
Merged

スキーマ変更に対応#31
kantacky merged 7 commits intomainfrom
update-spec

Conversation

@kantacky
Copy link
Member

@kantacky kantacky commented Feb 4, 2026

やったこと

  • YAML ファイル差し替え
  • コード生成
  • ハンドラを修正

確認したこと

  • dev 環境でアプリからお知らせを取得できること
  • dev 環境でAdminからCRUDできること

@kantacky kantacky self-assigned this Feb 4, 2026
v0関連の型・ハンドラーを削除し、Createレスポンスを201に変更、
新規のDetailエンドポイントハンドラーを追加した。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@kantacky kantacky marked this pull request as ready for review February 5, 2026 06:23
@kantacky kantacky requested review from a team, Copilot, hikaru-0602 and masaya-osuga February 5, 2026 06:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adapts the codebase to schema changes by removing deprecated v0 API endpoints and fields while adding a new detail endpoint for announcements.

Changes:

  • Removed deprecated v0 /announcements endpoint and associated handlers
  • Added new GET /v1/announcements/{id} detail endpoint
  • Removed deprecated date and isActive fields from domain, database, and API models
  • Updated create endpoint response code from 200 to 201 (more RESTful)

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
openapi/openapi.yaml Removed v0 endpoint, added v1 detail endpoint, removed deprecated fields from schema, changed create response to 201
internal/domain/announcement.go Removed deprecated Date and IsActive fields
internal/database/announcement.go Removed deprecated fields, removed explicit table name method, removed varchar length constraints
internal/repository/announcement.go Updated query to use available_until instead of is_active, updated sort to use available_from instead of date
internal/handler/get_announcements_v0.go Deleted v0 list handler
internal/handler/get_announcements_v1.go Renamed converter function from toDomainAnnouncementQueryV1 to toDomainAnnouncementQuery
internal/handler/get_announcement_v1.go New detail handler for fetching single announcement by ID
internal/handler/create_announcement.go Removed time.Now() parameter, changed response type to 201
internal/handler/update_announcement.go Removed time.Now() parameter from converter call
internal/handler/converter.go Removed deprecated field mappings and v0 converter functions, removed time.Now() parameter from converter
internal/handler/announcement_test.go Renamed test from V0 to V1, updated test data and assertions
generated/api.gen.go Removed v0 endpoint code, added v1 detail endpoint code, removed deprecated fields, changed create response to 201

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

announcement, err := h.announcementService.GetAnnouncementByID(ctx, request.Id)
if err != nil {
if errors.Is(err, domain.ErrNotFound) {
return nil, err // TODO: 404レスポンスを返すべき
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The TODO comment indicates incomplete error handling. The handler should return a proper 404 response when an announcement is not found, but currently it's returning the error directly which may not provide the correct HTTP status code. Consider implementing proper 404 response handling similar to other HTTP handlers in the codebase.

Suggested change
return nil, err // TODO: 404レスポンスを返すべき
return api.AnnouncementsV1Detail404JSONResponse{}, nil

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +23
func (h *Handler) AnnouncementsV1Detail(ctx context.Context, request api.AnnouncementsV1DetailRequestObject) (api.AnnouncementsV1DetailResponseObject, error) {
announcement, err := h.announcementService.GetAnnouncementByID(ctx, request.Id)
if err != nil {
if errors.Is(err, domain.ErrNotFound) {
return nil, err // TODO: 404レスポンスを返すべき
}
return nil, err
}

return api.AnnouncementsV1Detail200JSONResponse{
Announcement: toApiAnnouncement(announcement),
}, nil
}
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The new detail endpoint AnnouncementsV1Detail lacks test coverage. The codebase has test coverage for the list endpoint (TestAnnouncementsV1List), so this new endpoint should also have corresponding tests to verify correct behavior, error handling for non-existent IDs, and proper response formatting.

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +12
Title string `gorm:"not null"`
URL string `gorm:"not null"`
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The removal of varchar length constraints from Title and URL fields may have database migration implications. The previous constraints were type:varchar(500) for Title and type:varchar(1000) for URL. When GORM AutoMigrate runs, it may not automatically adjust existing column types in the database. Consider adding a database migration to ensure the schema is updated properly, or verify that the database already has compatible column types that can handle the change.

Copilot uses AI. Check for mistakes.
Copy link
Member

@masaya-osuga masaya-osuga left a comment

Choose a reason for hiding this comment

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

LGTM

@kantacky kantacky merged commit 63e9547 into main Feb 5, 2026
11 checks passed
@kantacky kantacky deleted the update-spec branch February 5, 2026 07:38
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