Changes in Models for debugging purposes:

- Replaces gorm.Model with ID uint for primary_key
    - Deactivates association_autoupdate for every association
This commit is contained in:
smavros 2019-04-22 11:45:17 +02:00
parent deffe181e5
commit 518af7ca65

View file

@ -1,13 +1,14 @@
package common package common
import ( import (
"github.com/jinzhu/gorm" //"github.com/jinzhu/gorm"
"github.com/jinzhu/gorm/dialects/postgres" "github.com/jinzhu/gorm/dialects/postgres"
"time" "time"
) )
type Simulator struct { type Simulator struct {
gorm.Model //gorm.Model
ID uint `gorm:"primary_key;auto_increment"`
UUID string `gorm:"unique;not null"` UUID string `gorm:"unique;not null"`
Host string `gorm:"default:''"` Host string `gorm:"default:''"`
Modeltype string `gorm:"default:''"` Modeltype string `gorm:"default:''"`
@ -19,7 +20,8 @@ type Simulator struct {
} }
type File struct { type File struct {
gorm.Model //gorm.Model
ID uint `gorm:"primary_key;auto_increment"`
Name string `gorm:"not null"` Name string `gorm:"not null"`
Path string `gorm:"not null"` Path string `gorm:"not null"`
Type string `gorm:"not null"` Type string `gorm:"not null"`
@ -33,7 +35,8 @@ type File struct {
} }
type Project struct { type Project struct {
gorm.Model //gorm.Model
ID uint `gorm:"primary_key;auto_increment"`
Name string `gorm:"not null"` Name string `gorm:"not null"`
User User `gorm:"not null;association_autoupdate:false"` User User `gorm:"not null;association_autoupdate:false"`
@ -42,11 +45,12 @@ type Project struct {
Simulation Simulation `gorm:"not null;association_autoupdate:false"` Simulation Simulation `gorm:"not null;association_autoupdate:false"`
SimulationID uint `gorm:"not null"` SimulationID uint `gorm:"not null"`
Visualizations []Visualization //`gorm:"association_autoupdate:false"` Visualizations []Visualization `gorm:"association_autoupdate:false"`
} }
type Simulation struct { type Simulation struct {
gorm.Model //gorm.Model
ID uint `gorm:"primary_key;auto_increment"`
Name string `gorm:"not null"` Name string `gorm:"not null"`
Running bool `gorm:"default:false"` Running bool `gorm:"default:false"`
StartParameters postgres.Jsonb // TODO default value StartParameters postgres.Jsonb // TODO default value
@ -54,12 +58,13 @@ type Simulation struct {
User User `gorm:"not null;association_autoupdate:false"` User User `gorm:"not null;association_autoupdate:false"`
UserID uint `gorm:"not null"` UserID uint `gorm:"not null"`
Models []SimulationModel `gorm:"foreignkey:BelongsToSimulationID"` //;association_autoupdate:false"` Models []SimulationModel `gorm:"foreignkey:BelongsToSimulationID;association_autoupdate:false"`
Projects []Project `gorm:"association_autoupdate:false"` Projects []Project `gorm:"association_autoupdate:false"`
} }
type SimulationModel struct { type SimulationModel struct {
gorm.Model //gorm.Model
ID uint `gorm:"primary_key;auto_increment"`
Name string `gorm:"not null"` Name string `gorm:"not null"`
OutputLength int `gorm:"default:1"` OutputLength int `gorm:"default:1"`
InputLength int `gorm:"default:1"` InputLength int `gorm:"default:1"`
@ -72,24 +77,26 @@ type SimulationModel struct {
BelongsToSimulatorID uint `gorm:"not null"` BelongsToSimulatorID uint `gorm:"not null"`
// NOTE: order of signals is important // NOTE: order of signals is important
OutputMapping []Signal //`gorm:"association_autoupdate:false"` OutputMapping []Signal `gorm:"association_autoupdate:false"`
InputMapping []Signal //`gorm:"association_autoupdate:false"` InputMapping []Signal `gorm:"association_autoupdate:false"`
} }
type User struct { type User struct {
gorm.Model //gorm.Model
ID uint `gorm:"primary_key;auto_increment"`
Username string `gorm:"unique;not null"` Username string `gorm:"unique;not null"`
Password string `gorm:"not null"` Password string `gorm:"not null"`
Mail string `gorm:"default:''"` Mail string `gorm:"default:''"`
Role string `gorm:"default:'user'"` Role string `gorm:"default:'user'"`
Projects []Project //`gorm:"association_autoupdate:false"` Projects []Project `gorm:"association_autoupdate:false"`
Simulations []Simulation //`gorm:"association_autoupdate:false"` Simulations []Simulation `gorm:"association_autoupdate:false"`
Files []File //`gorm:"association_autoupdate:false"` Files []File `gorm:"association_autoupdate:false"`
} }
type Visualization struct { type Visualization struct {
gorm.Model //gorm.Model
ID uint `gorm:"primary_key;auto_increment"`
Name string `gorm:"not null"` Name string `gorm:"not null"`
Grid int `gorm:"default:15"` Grid int `gorm:"default:15"`
@ -99,11 +106,12 @@ type Visualization struct {
User User `gorm:"not null;association_autoupdate:false"` User User `gorm:"not null;association_autoupdate:false"`
UserID uint `gorm:"not null"` UserID uint `gorm:"not null"`
Widgets []Widget //`gorm:"association_autoupdate:false"` Widgets []Widget `gorm:"association_autoupdate:false"`
} }
type Signal struct { type Signal struct {
gorm.Model //gorm.Model
ID uint `gorm:"primary_key;auto_increment"`
Name string `gorm:"not null"` Name string `gorm:"not null"`
Unit string `gorm:"not null"` Unit string `gorm:"not null"`
SimulationModelID uint SimulationModelID uint
@ -111,7 +119,8 @@ type Signal struct {
} }
type Widget struct { type Widget struct {
gorm.Model //gorm.Model
ID uint `gorm:"primary_key;auto_increment"`
Name string `gorm:"not null"` Name string `gorm:"not null"`
Type string `gorm:"not null"` Type string `gorm:"not null"`
Width uint `gorm:"not null"` Width uint `gorm:"not null"`