Skip to content

Commit

Permalink
Merge pull request #518 from traPtitech/fix/v8_migration
Browse files Browse the repository at this point in the history
v8のmigration修正
  • Loading branch information
mazrean authored Oct 27, 2022
2 parents 984d186 + fad8e62 commit 312fa17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/repository/gorm2/migrate/v8.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ func v8() *gormigrate.Migration {
"FROM game_versions " +
"LEFT JOIN games ON game_versions.game_id = games.id " +
"LEFT JOIN (SELECT * FROM game_images AS gi1 WHERE id = (" +
"SELECT id FROM game_images AS gi2 WHERE gi1.game_id = gi2.game_id ORDER BY gi2.created_at LIMIT 1" +
"SELECT id FROM game_images AS gi2 WHERE gi1.game_id = gi2.game_id ORDER BY gi2.created_at DESC LIMIT 1" +
")) AS game_images ON games.id = game_images.game_id " +
"LEFT JOIN (SELECT * FROM game_videos AS gv1 WHERE id = (" +
"SELECT id FROM game_videos AS gv2 WHERE gv1.game_id = gv2.game_id ORDER BY gv2.created_at LIMIT 1)" +
") AS game_videos ON games.id = game_videos.game_id " +
"SELECT id FROM game_videos AS gv2 WHERE gv1.game_id = gv2.game_id ORDER BY gv2.created_at DESC LIMIT 1" +
")) AS game_videos ON games.id = game_videos.game_id " +
"LEFT JOIN game_urls ON game_versions.id = game_urls.game_version_id").Error
if err != nil {
return fmt.Errorf("failed to migrate v2_game_versions table: %w", err)
Expand Down Expand Up @@ -81,7 +81,7 @@ func v8() *gormigrate.Migration {
"(edition_id, game_version_id) " +
"SELECT launcher_version_game_relations.launcher_version_table_id, game_versions.id " +
"FROM launcher_version_game_relations " +
"LEFT JOIN (SELECT * FROM game_versions AS gv1 WHERE id = (SELECT id FROM game_versions AS gv2 WHERE gv1.game_id = gv2.game_id ORDER BY gv2.created_at LIMIT 1)) AS game_versions ON launcher_version_game_relations.game_table_id = game_versions.game_id").Error
"LEFT JOIN (SELECT * FROM game_versions AS gv1 WHERE id = (SELECT id FROM game_versions AS gv2 WHERE gv1.game_id = gv2.game_id ORDER BY gv2.created_at DESC LIMIT 1)) AS game_versions ON launcher_version_game_relations.game_table_id = game_versions.game_id").Error
if err != nil {
return fmt.Errorf("failed to migrate edition_game_version_relations table: %w", err)
}
Expand Down
4 changes: 0 additions & 4 deletions src/service/v2/edition.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"log"
"time"

"github.com/google/uuid"
"github.com/traPtitech/trap-collection-server/pkg/types"
"github.com/traPtitech/trap-collection-server/src/domain"
"github.com/traPtitech/trap-collection-server/src/domain/values"
Expand Down Expand Up @@ -328,7 +327,6 @@ func (edition *Edition) GetEditionGameVersions(ctx context.Context, editionID va
gameIDs = append(gameIDs, gameVersion.GameID)
fileIDs = append(fileIDs, gameVersion.FileIDs...)
}
log.Printf("game_ids: %d, %+v\n", len(gameIDs), gameIDs)

games, err := edition.gameRepository.GetGamesByIDs(ctx, gameIDs, repository.LockTypeNone)
if err != nil {
Expand All @@ -339,7 +337,6 @@ func (edition *Edition) GetEditionGameVersions(ctx context.Context, editionID va
for _, game := range games {
gameMap[game.GetID()] = game
}
log.Printf("game_map: %d, %+v\n", len(gameMap), gameMap)

files, err := edition.gameFileRepository.GetGameFilesWithoutTypes(ctx, fileIDs, repository.LockTypeNone)
if err != nil {
Expand All @@ -355,7 +352,6 @@ func (edition *Edition) GetEditionGameVersions(ctx context.Context, editionID va
for _, gameVersion := range gameVersions {
game, ok := gameMap[gameVersion.GameID]
if !ok {
log.Printf("game_id(false): %s\n", uuid.UUID(gameVersion.GameID))
return nil, errors.New("game not found")
}

Expand Down

0 comments on commit 312fa17

Please sign in to comment.