Joe Chen 083c3ee659
db: refactor "action" table to use GORM (#7054)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2022-06-25 18:07:39 +08:00

20 lines
438 B
Go

// Copyright 2022 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package migrations
import (
"gorm.io/gorm"
)
func addIndexToActionUserID(db *gorm.DB) error {
type action struct {
UserID string `gorm:"index"`
}
if db.Migrator().HasIndex(&action{}, "UserID") {
return nil
}
return db.Migrator().CreateIndex(&action{}, "UserID")
}