24 lines
850 B
Go
24 lines
850 B
Go
// Code generated by summer make. DO NOT EDIT.
|
|
|
|
package updates
|
|
|
|
import (
|
|
"github.com/go-gormigrate/gormigrate/v2"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// AddCompletedAttemptsIndex returns the 20261002121917_add_completed_attempts_index gormigrate entry.
|
|
// The partial index serves the per-user statistics of the quiz list (count
|
|
// and best score of completed attempts).
|
|
func AddCompletedAttemptsIndex() *gormigrate.Migration {
|
|
return &gormigrate.Migration{
|
|
ID: "20261002121917_add_completed_attempts_index",
|
|
Migrate: func(tx *gorm.DB) error {
|
|
return tx.Exec("CREATE INDEX golem15_quizzes_attempts_completed_index ON golem15_quizzes_attempts (user_id, quiz_id, score_percent) WHERE completed_at IS NOT NULL").Error
|
|
},
|
|
Rollback: func(tx *gorm.DB) error {
|
|
return tx.Exec("DROP INDEX IF EXISTS golem15_quizzes_attempts_completed_index").Error
|
|
},
|
|
}
|
|
}
|