66 lines
2.2 KiB
Go
66 lines
2.2 KiB
Go
package models
|
|
|
|
type _Asset struct {
|
|
ID uint `gorm:"primaryKey`
|
|
Name string `gorm:"not null"`
|
|
Notes string
|
|
}
|
|
|
|
type Land struct {
|
|
_Asset
|
|
FID string `gorm:"not null"`
|
|
IsWaterProtectionArea bool `gorm:"not null"`
|
|
IsRedArea bool `gorm:"not null"`
|
|
Betriebsnummer?
|
|
Area float64 `gorm:"not null"`
|
|
}
|
|
|
|
type Plant struct {
|
|
_Asset
|
|
LandId uint `gorm:"not null"`
|
|
Land Land `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
|
CropID uint `gorm:"not null"`
|
|
Crop Taxonomy `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
|
CoverCropID uint `gorm:"not null"`
|
|
CoverCrop Taxonomy `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
|
Year uint `gorm:"not null"`
|
|
AreaPercentage float64 `gorm:"not null"`
|
|
}
|
|
|
|
type Machine struct {
|
|
_Asset
|
|
UnitID uint `gorm:"not null"`
|
|
Unit Taxonomy `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
|
Cost float64 `gorm:"not null; type:decimal(10,2);"` // in euro
|
|
}
|
|
|
|
type SeedType struct {
|
|
ID uint `gorm:"primaryKey`
|
|
Name string `gorm:"not null"`
|
|
CropID uint `gorm:"not null"`
|
|
Crop Taxonomy `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
|
}
|
|
|
|
type Seed struct {
|
|
_Asset
|
|
BuyDate Datetime.Time `gorm:"type:date;default:CURRENT_DATE"`
|
|
UnitID uint `gorm:"not null"`
|
|
Unit Taxonomy `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
|
Cost float64 `gorm:"not null; type:decimal(10,2);"` // in euro/unit
|
|
SourcedFromID uint `gorm:"not null"`
|
|
SourcedFrom Taxonomy `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
|
SeedTypeID uint `gorm:"not null"`
|
|
SeedType SeedType `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
|
}
|
|
|
|
type Fertilizer struct {
|
|
_Asset
|
|
BuyDate Datetime.Time `gorm:"type:date;default:CURRENT_DATE"`
|
|
UnitID uint `gorm:"not null"`
|
|
Unit Taxonomy `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
|
Cost float64 `gorm:"not null; type:decimal(10,2);"` // in euro/unit
|
|
SourcedFromID uint `gorm:"not null"`
|
|
SourcedFrom Taxonomy `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
|
FertilizerTypeID uint `gorm:"not null"`
|
|
FertilizerType Taxonomy `gorm:"not null; constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
|
|
} |