Lots of changes
This commit is contained in:
@ -6,7 +6,10 @@ import (
|
||||
|
||||
type Benchmark struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
Name string
|
||||
ScoringType string
|
||||
Description string
|
||||
|
||||
// many-to-many test
|
||||
Tests[] Test `gorm:"many2many:tests_benchmarks;"`
|
||||
}
|
||||
|
@ -6,8 +6,10 @@ import (
|
||||
|
||||
type Hardware struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
Type string
|
||||
SerialNumber string
|
||||
Name string
|
||||
Type string
|
||||
Description string
|
||||
|
||||
// has many tests
|
||||
Tests[] Test
|
||||
}
|
||||
|
@ -21,6 +21,6 @@ func Open() {
|
||||
}
|
||||
|
||||
// Migrate the schema
|
||||
DB.AutoMigrate(&Project{}, &Hardware{}, &Benchmark{})
|
||||
DB.AutoMigrate(&Test{}, &Hardware{}, &Benchmark{})
|
||||
log.Println("Database migrations complete.")
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Project struct {
|
||||
gorm.Model
|
||||
Name string
|
||||
Description string
|
||||
}
|
17
models/test.go
Normal file
17
models/test.go
Normal file
@ -0,0 +1,17 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Test struct {
|
||||
gorm.Model
|
||||
DateTag string
|
||||
|
||||
// belongs to hardware
|
||||
HardwareID int
|
||||
Hardware Hardware
|
||||
|
||||
// many-to-many benchmarks
|
||||
Benchmarks[] Benchmark `gorm:"many2many:tests_benchmarks;"`
|
||||
}
|
Reference in New Issue
Block a user