fix(realname): DB 迁移 + Model + Store 清理 REALNAME-01

- 新增迁移 000089: 移除 enable_realname_activation,添加 expiry_base 字段
- package.go: 删除 EnableRealnameActivation 字段,新增 ExpiryBase 字段
- package_store.go: 移除两步写入特殊处理,改为直接一步 Create
This commit is contained in:
2026-03-28 10:36:31 +08:00
parent 2a92ab64af
commit 344850fe1d
4 changed files with 40 additions and 24 deletions

View File

@@ -20,12 +20,7 @@ func NewPackageStore(db *gorm.DB) *PackageStore {
}
func (s *PackageStore) Create(ctx context.Context, pkg *model.Package) error {
// GORM 对零值字段有特殊处理,先创建然后立即更新 enable_realname_activation 字段确保正确设置
if err := s.db.WithContext(ctx).Omit("enable_realname_activation").Create(pkg).Error; err != nil {
return err
}
// 明确更新 enable_realname_activation 字段(包括零值 false
return s.db.WithContext(ctx).Model(pkg).Update("enable_realname_activation", pkg.EnableRealnameActivation).Error
return s.db.WithContext(ctx).Create(pkg).Error
}
func (s *PackageStore) GetByID(ctx context.Context, id uint) (*model.Package, error) {