Files
RenewCMS/internal/infrastructure/persistence/database/migrationMarker.go
T

26 lines
582 B
Go

package database
import (
entity "RenewCMS/internal/infrastructure/persistence/models"
"time"
"gorm.io/gorm"
)
const (
legacyUserRolesMarker = "legacy_user_roles"
inviteRolesMarker = "invite_roles"
)
func markerApplied(tx *gorm.DB, name string) (bool, error) {
var count int64
if err := tx.Model(&entity.MigrationMarker{}).Where("name = ?", name).Count(&count).Error; err != nil {
return false, err
}
return count > 0, nil
}
func applyMarker(tx *gorm.DB, name string) error {
return tx.Create(&entity.MigrationMarker{Name: name, AppliedAt: time.Now()}).Error
}