upd store

This commit is contained in:
Vladimir V Maksimov
2025-11-06 16:50:12 +03:00
parent 488f11bd56
commit 00b12cdf7d
8 changed files with 269 additions and 117 deletions

28
models/version.go Normal file
View File

@@ -0,0 +1,28 @@
package models
import (
"encoding/json"
"time"
"github.com/google/uuid"
)
// Version — конкретная версия документа
type Version struct {
ID uuid.UUID `gorm:"type:char(36);primaryKey"`
DocumentID uuid.UUID `gorm:"type:char(36);index"`
ParentID *uuid.UUID `gorm:"type:char(36);"`
IsSnapshot bool
Patch json.RawMessage `gorm:"type:json"` // JSON Patch или nil, если Snapshot
Snapshot json.RawMessage `gorm:"type:json"` // Полный JSON, если IsSnapshot = true
CreatedAt time.Time
}
func (s *Version) TableName() (res string) {
if SchemeName != "" {
res = SchemeName + ".version"
} else {
res = "version"
}
return
}