package database import ( "orbits-server/internal/shared/utility" "time" ) type Timestamps struct { CreatedAt time.Time `gorm:"not null;"` UpdatedAt time.Time `gorm:"not null;"` ExpiresAt time.Time } type Command struct { ID int `gorm:"primaryKey;not null;"` State string // unspecified // video // presentation // internet URL MediaType utility.MediaType `gorm:"type:varchar(20);not null;"` // Must specify what kind of file it is // Must be target list who are compelled to listen to the command // can be none when there is no targets specified (init stage) Targets []string `gorm:"type:json;"` // Must be the location where the file is downloadable on the API // can be none when there is no media specified (init stage) Location string Timestamps } type AccessKey struct { ID int `gorm:"primaryKey;not null;"` MetaName string KeyName string `gorm:"not null;"` // We don't store the key itself, we hash the key KeyHash string `gorm:"not null;"` // we're cooking without pepper Timestamps } type Tenant struct { ID int `gorm:"primaryKey;not null;"` TenantName string `gorm:"not null"` TenantDescription string Groups []Group `gorm:"foreignKey:TenantID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` Timestamps } type Group struct { ID int `gorm:"primaryKey;not null;"` TenantID uint `gorm:"not null;index"` GroupName string `gorm:"not null;"` GroupDescription string Devices []Device `gorm:"foreignKey:GroupID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` Timestamps } type Device struct { ID int `gorm:"primaryKey;not null;"` GroupID uint `gorm:"not null;index"` // Device type is meant as a field where can be specified what type of device this is // eg Raspberry Pi, PC, things like that DeviceType string Hostname string `gorm:"not null;"` RemoteAddress string `gorm:"not null;"` Alive bool `gorm:"not null;"` Compliant bool `gorm:"not null;"` Timestamps } type File struct { ID int `gorm:"primaryKey;not null;"` // unspecified // video // presentation // internet URL MediaType utility.MediaType `gorm:"type:varchar(20);not null;"` // the name given by the user MetaName string FileName string `gorm:"not null;"` FilePath string `gorm:"not null;"` // hex encoded sha512 checksum Checksum string `gorm:"uniqueIndex;not null;"` Timestamps }