v21.go 634 B

1234567891011121314151617181920212223
  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 and LICENSE.gogs file.
  4. // Copyright 2025 Huan-Gogs Authors. All rights reserved.
  5. // Use of this source code is governed by a MIT-style
  6. // license that can be found in the LICENSE file.
  7. package migrations
  8. import (
  9. "gorm.io/gorm"
  10. )
  11. func addIndexToActionUserID(db *gorm.DB) error {
  12. type action struct {
  13. UserID string `gorm:"index"`
  14. }
  15. if db.Migrator().HasIndex(&action{}, "UserID") {
  16. return errMigrationSkipped
  17. }
  18. return db.Migrator().CreateIndex(&action{}, "UserID")
  19. }