61 lines
995 B
Go
61 lines
995 B
Go
// Define all Database Models here
|
|
package db
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type User struct {
|
|
gorm.Model
|
|
Name string `gorm:"unique;index"`
|
|
PassHash string
|
|
Email string
|
|
DisplayName string
|
|
Groups []Group `gorm:"many2many:user_groups"`
|
|
Admin bool
|
|
}
|
|
|
|
type Group struct {
|
|
gorm.Model
|
|
Name string `grom:"unique;index"`
|
|
DisplayName string
|
|
Users []User `gorm:"many2many:user_groups"`
|
|
}
|
|
|
|
type Subnet struct {
|
|
gorm.Model
|
|
Name string `grom:"unique;index"`
|
|
DisplayName string
|
|
VLAN int
|
|
IPv4Net string
|
|
IPv6Net string
|
|
LocationID uint
|
|
Comment string
|
|
}
|
|
|
|
type Location struct {
|
|
gorm.Model
|
|
Name string
|
|
Comment string
|
|
Subnets []Subnet
|
|
}
|
|
|
|
type Address struct {
|
|
gorm.Model
|
|
Name string
|
|
Comment string
|
|
IPv4Address string
|
|
IPv6Address string
|
|
MACAddress string
|
|
DNSName string
|
|
DeviceID uint
|
|
SubnetID uint
|
|
}
|
|
|
|
type Device struct {
|
|
gorm.Model
|
|
Name string
|
|
Comment string
|
|
Addresses []Address
|
|
}
|