feat: add the quizzes:import command for JSON quiz files

This commit is contained in:
Jakub Zych
2026-10-02 14:20:33 +02:00
parent 793cc4aac0
commit d05bee4e50
9 changed files with 551 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
// 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
},
}
}