feat: image variants engine
This commit is contained in:
1 parent
f0845de643
commit
f1d56ef50e
80 files changed
+7312
-84
No files matched your search
@@ -7,9 +7,29 @@ import (
|
||||
)
|
||||
|
||||
func Migrate(db *gorm.DB) error {
|
||||
err := tableOptionsFor(db).AutoMigrate(&models.Article{}, &models.Image{}, &models.User{}, &models.Invite{}, &models.APIKey{}, &models.PurgeSettings{}, &models.AuditEvent{}, &models.AuditSettings{})
|
||||
err := tableOptionsFor(db).AutoMigrate(&models.Article{}, &models.Image{}, &models.User{}, &models.Invite{}, &models.APIKey{}, &models.PurgeSettings{}, &models.AuditEvent{}, &models.AuditSettings{}, &models.ImageVariant{}, &models.ImageVariantFile{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ensureImagePathIndex(db); err != nil {
|
||||
return err
|
||||
}
|
||||
return BackfillUserRoles(db)
|
||||
}
|
||||
|
||||
const (
|
||||
imagePathIndexName = "idx_images_path"
|
||||
mysqlDialectorName = "mysql"
|
||||
imagePathIndexStatement = "CREATE INDEX " + imagePathIndexName + " ON images (path)"
|
||||
mysqlImagePathStatement = "CREATE INDEX " + imagePathIndexName + " ON images (path(191))"
|
||||
)
|
||||
|
||||
func ensureImagePathIndex(db *gorm.DB) error {
|
||||
if db.Migrator().HasIndex(&models.Image{}, imagePathIndexName) {
|
||||
return nil
|
||||
}
|
||||
if db.Dialector.Name() == mysqlDialectorName {
|
||||
return db.Exec(mysqlImagePathStatement).Error
|
||||
}
|
||||
return db.Exec(imagePathIndexStatement).Error
|
||||
}
|
||||
Reference in new issue
Block a user