changes for influxdb

This commit is contained in:
2026-02-04 14:58:13 +01:00
parent a78c6952f0
commit 97679561d8
5 changed files with 164 additions and 194 deletions

View File

@@ -1,47 +1,38 @@
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"`
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"`
Time time.Time
Application string
Device string
Attributes map[string]interface{}
Values map[string]VariableType
}
// Simplified structures for backward compatibility
type DeviceType struct {
Label string
ModelIdentifier string
Attributes map[string]interface{}
}
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"`
Label string
Attributes map[string]interface{}
}
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"`
Label string
Application Application
DeviceType DeviceType
Attributes map[string]interface{}
}