超表改造
This commit is contained in:
@@ -25,8 +25,13 @@ const (
|
||||
)
|
||||
|
||||
// PlanExecutionLog 记录整个计划的一次执行历史
|
||||
|
||||
type PlanExecutionLog struct {
|
||||
gorm.Model
|
||||
ID uint `gorm:"primaryKey"`
|
||||
CreatedAt time.Time `gorm:"primaryKey"` // 作为联合主键方便只查询热点数据
|
||||
UpdatedAt time.Time
|
||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||
|
||||
PlanID uint `gorm:"index"`
|
||||
Status ExecutionStatus
|
||||
StartedAt time.Time
|
||||
@@ -41,7 +46,11 @@ func (PlanExecutionLog) TableName() string {
|
||||
|
||||
// TaskExecutionLog 记录单个任务的一次执行历史
|
||||
type TaskExecutionLog struct {
|
||||
gorm.Model
|
||||
ID uint `gorm:"primaryKey"`
|
||||
CreatedAt time.Time `gorm:"primaryKey"` // 作为联合主键方便只查询热点数据
|
||||
UpdatedAt time.Time
|
||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||
|
||||
PlanExecutionLogID uint `gorm:"index"` // 关联到某次计划执行
|
||||
|
||||
// TaskID 使用 int 类型以容纳特殊的负数ID,代表系统任务
|
||||
@@ -100,7 +109,7 @@ type DeviceCommandLog struct {
|
||||
DeviceID uint `gorm:"not null;index" json:"device_id"`
|
||||
|
||||
// SentAt 记录下行任务最初发送的时间。
|
||||
SentAt time.Time `gorm:"not null" json:"sent_at"`
|
||||
SentAt time.Time `gorm:"primaryKey" json:"sent_at"`
|
||||
|
||||
// AcknowledgedAt 记录设备确认收到下行消息的时间。
|
||||
// 如果设备未确认,则为零值或 NULL。使用指针类型 *time.Time 允许 NULL 值。
|
||||
@@ -136,7 +145,7 @@ type PendingCollection struct {
|
||||
FulfilledAt *time.Time
|
||||
|
||||
// CreatedAt 是 GORM 的标准字段,记录请求创建时间。
|
||||
CreatedAt time.Time
|
||||
CreatedAt time.Time `gorm:"primaryKey"`
|
||||
}
|
||||
|
||||
// TableName 自定义 GORM 使用的数据库表名
|
||||
@@ -175,7 +184,7 @@ type UserActionLog struct {
|
||||
Time time.Time `gorm:"primaryKey" json:"time"`
|
||||
|
||||
// --- Who (谁) ---
|
||||
UserID uint `gorm:"index" json:"user_id,omitempty"`
|
||||
UserID uint `gorm:"primaryKey" json:"user_id,omitempty"`
|
||||
Username string `json:"username,omitempty"` // 操作发生时用户名的快照
|
||||
|
||||
// --- Where (何地) ---
|
||||
|
||||
Reference in New Issue
Block a user