This commit is contained in:
Vladimir V Maksimov
2025-11-04 00:18:00 +03:00
parent 1ce7af3663
commit 488f11bd56
8 changed files with 532 additions and 0 deletions

28
models/models.go Normal file
View File

@@ -0,0 +1,28 @@
package models
import (
"encoding/json"
"time"
"github.com/google/uuid"
)
// Document — логическая сущность (например, пользователь, настройки и т.п.)
type Document struct {
ID uuid.UUID `gorm:"type:char(36);primaryKey"`
Name string
CreatedAt time.Time
UpdatedAt time.Time
LatestVersion uuid.UUID `gorm:"type:char(36);"`
}
// 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
}