diff --git a/go/main.go b/go/main.go index 174e580..3eb6751 100644 --- a/go/main.go +++ b/go/main.go @@ -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", diff --git a/sql/init.sql b/sql/init.sql index a02fa27..399dea1 100644 --- a/sql/init.sql +++ b/sql/init.sql @@ -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`);