diff --git a/file/model.go b/file/model.go index e855e79..bbd1bb7 100644 --- a/file/model.go +++ b/file/model.go @@ -2,14 +2,16 @@ package file import ( "github.com/jinzhu/gorm" + "time" ) type File struct { gorm.Model Name string - Path string + Path string `gorm:"not null"` Type string Size uint - Dimmensions string - FileUser User + Dimmensions string // TODO: Mixed Type + FileUser User `gorm:"not null"` + Date Time `gorm:"default:Time.Now"` } diff --git a/project/model.go b/project/model.go index 46174b5..e154892 100644 --- a/project/model.go +++ b/project/model.go @@ -8,10 +8,10 @@ import ( type Project struct { gorm.Model - Name string - UserProject User // XXX: association? - Visualizations []Visualization // TODO: association & foreign key - SimulationProject Simulation // XXX: association?n + Name string `gorm:"not null"` + ProjectUser User `gorm:"not null"` + Visualizations []Visualization + ProjectSimulation Simulation `gorm:"not null"` } // TODO: execute before project.delete() diff --git a/simulation/model.go b/simulation/model.go index 6b7bf45..066eae6 100644 --- a/simulation/model.go +++ b/simulation/model.go @@ -8,10 +8,10 @@ import ( type Simulation struct { gorm.Model - Name string - Running bool `gorm:"default:false"` - Models []SimulationModel // TODO: association & foreign key - Projects []Project // TODO: association & foreign key - User []Users // TODO: association & foreign key - StartParameters []string // TODO: Mixed Type + Name string `gorm:"not null"` + Running bool `gorm:"default:false"` + Models []SimulationModel + Projects []Project + SimulationUser User `gorm:"not null"` + StartParameters []string // TODO: Mixed Type } diff --git a/simulationModel/model.go b/simulationModel/model.go index b6872dc..4e1d2ba 100644 --- a/simulationModel/model.go +++ b/simulationModel/model.go @@ -13,6 +13,6 @@ type SimulationModel struct { OutputMapping []string // TODO: Mixed Type InputMapping []string // TODO: Mixed Type StartParameters []string // TODO: Mixed Type - ModelSimulation Simulation // TODO: association & foreign key - ModelSimulator Simulator // TODO: association & foreign key + ModelSimulation Simulation `gorm:"not null"` + ModelSimulator Simulator `gorm:"not null"` } diff --git a/simulator/model.go b/simulator/model.go index 02d1b94..1903ae9 100644 --- a/simulator/model.go +++ b/simulator/model.go @@ -2,15 +2,17 @@ package simulator import ( "github.com/jinzhu/gorm" + "time" ) type Simulator struct { gorm.Model - UUID string - Host string `gorm:"default:"` - Model string `gorm:"default:"` - Uptime int `gorm:"default:0"` - State string `gorm:"default:"` - Properties []string - RawProperties []string + UUID string `gorm:"unique;not null"` + Host string `gorm:"default:"` + Model string `gorm:"default:"` + Uptime int `gorm:"default:0"` + State string `gorm:"default:"` + StateUpdateAt Time `gorm:"default:Time.Now"` + Properties []string // TODO: mixed type + RawProperties []string // TODO: mixed type } diff --git a/user/model.go b/user/model.go index 7045f1a..7047a6e 100644 --- a/user/model.go +++ b/user/model.go @@ -10,13 +10,13 @@ import ( type User struct { gorm.Model - Username string `gorm:"unique"` - Password string - Mail string `gorm:"default:"` - Role string `gorm:"default:user"` - Projects []Project // TODO: association & foreign key - Simulations []Simulaion // TODO: association & foreign key - Files []File // TODO: association & foreign key + Username string `gorm:"unique;not null"` + Password string `gorm:"not null"` + Mail string `gorm:"default:"` + Role string `gorm:"default:user"` + Projects []Project + Simulations []Simulaion + Files []File } // TODO: callback for verifying password diff --git a/visualization/model.go b/visualization/model.go index 9e64522..9226441 100644 --- a/visualization/model.go +++ b/visualization/model.go @@ -6,9 +6,9 @@ import ( type Visualization struct { gorm.Model - Name string - VisualizationProject Project - Widgets string - Grid int `gorm:"default:15"` - VisualizationUser User + Name string `gorm:"not null"` + VisualizationProject Project `gorm:"not null"` + Widgets []string // XXX: array of what type? + Grid int `gorm:"default:15"` + VisualizationUser User `gorm:"not null"` }