package database import "time" import "gorm.io/gorm" type VariableType struct { Label string `json:"label"` Variable string `json:"variable"` Unit string `json:"unit"` Value interface{} `json:"value,omitempty"` Status string `json:"status,omitempty"` } type Measurement struct { Time time.Time `gorm:"not null;primary_key"` Application string `gorm:"not null"` Device string Attributes map[string]interface{} `gorm:"serializer:json;type:jsonb"` Values map[string]VariableType `gorm:"serializer:json;type:jsonb"` } type Application struct { gorm.Model Label string `gorm:"not null"` Attributes map[string]interface{} `gorm:"serializer:json;type:jsonb"` } type DeviceType struct { gorm.Model Label string `gorm:"not null"` ModelIdentifier string Attributes map[string]interface{} `gorm:"serializer:json;type:jsonb"` } type Device struct { gorm.Model Label string `gorm:"not null;uniqueIndex:idx_label_application_id"` ApplicationID int `gorm:"not null;uniqueIndex:idx_label_application_id"` Application Application DeviceTypeID int `gorm:"not null"` DeviceType DeviceType Attributes map[string]interface{} `gorm:"serializer:json;type:jsonb"` }