v21.go 454 B

1234567891011121314151617181920
  1. // Copyright 2022 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package migrations
  5. import (
  6. "gorm.io/gorm"
  7. )
  8. func addIndexToActionUserID(db *gorm.DB) error {
  9. type action struct {
  10. UserID string `gorm:"index"`
  11. }
  12. if db.Migrator().HasIndex(&action{}, "UserID") {
  13. return errMigrationSkipped
  14. }
  15. return db.Migrator().CreateIndex(&action{}, "UserID")
  16. }