Lots of changes

This commit is contained in:
2023-12-02 22:16:16 -05:00
parent 16704aeeb1
commit c5df026d04
16 changed files with 135 additions and 122 deletions

View File

@ -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;"`
}

View File

@ -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
}

View File

@ -21,6 +21,6 @@ func Open() {
}
// Migrate the schema
DB.AutoMigrate(&Project{}, &Hardware{}, &Benchmark{})
DB.AutoMigrate(&Test{}, &Hardware{}, &Benchmark{})
log.Println("Database migrations complete.")
}

View File

@ -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
View 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;"`
}