Skip to content

Commit

Permalink
go で index はる
Browse files Browse the repository at this point in the history
  • Loading branch information
a01sa01to committed Nov 25, 2023
1 parent c63955c commit 735cd39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 9 additions & 0 deletions go/main.go
Expand Up @@ -118,6 +118,15 @@ func initializeHandler(c echo.Context) error {
return echo.NewHTTPError(http.StatusInternalServerError, "failed to initialize: "+err.Error())
}

indexes := []string{
"CREATE INDEX `livestreams_user_id` ON `livestreams` (`user_id`)",
}
for _, index := range indexes {
if _, err := dbConn.Exec(index); err != nil {
c.Logger().Warnf("failed to create index: %s", err)
}
}

c.Request().Header.Add("Content-Type", "application/json;charset=utf-8")
return c.JSON(http.StatusOK, InitializeResponse{
Language: "golang",
Expand Down
2 changes: 0 additions & 2 deletions sql/init.sql
Expand Up @@ -23,5 +23,3 @@ ALTER TABLE `tags` auto_increment = 1;
ALTER TABLE `livecomments` auto_increment = 1;
ALTER TABLE `livestreams` auto_increment = 1;
ALTER TABLE `users` auto_increment = 1;

CREATE INDEX `livestream_tags_tag_id` ON `livestream_tags` (`livestream_id`);

0 comments on commit 735cd39

Please sign in to comment.