refac: migration crash, real-database tests, site deleted during create, ruels out of the repo, lists

This commit is contained in:
Florian Sylvain committed 2026-11-03 05:06:04 +01:00
1 parent 680b9a1308
commit 9d284e65a9
62 files changed
+1858 -987

No files matched your search

@@ -0,0 +1,20 @@
package database
import (
entity "RenewCMS/internal/infrastructure/persistence/models"
"gorm.io/gorm"
)
const (
sourceRevisionColumn = "source_revision"
untranslatedSourceValue = 0
)
func BackfillNullSourceRevisions(db *gorm.DB) error {
migrator := db.Migrator()
if !migrator.HasTable(&entity.Article{}) || !migrator.HasColumn(&entity.Article{}, sourceRevisionColumn) {
return nil
}
return db.Unscoped().Model(&entity.Article{}).Where(sourceRevisionColumn+" IS NULL").UpdateColumn(sourceRevisionColumn, untranslatedSourceValue).Error
}