feat(env_group): migrate site_category to env_group

This commit is contained in:
Jacky 2025-04-05 02:32:40 +00:00
parent de1860718e
commit a379211e3c
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
66 changed files with 4837 additions and 4251 deletions

View file

@ -1,6 +1,7 @@
package model
type SiteCategory struct {
// EnvGroup represents a group of environments that can be synced across nodes
type EnvGroup struct {
Model
Name string `json:"name"`
SyncNodeIds []uint64 `json:"sync_node_ids" gorm:"serializer:json"`

View file

@ -1,9 +1,10 @@
package model
import (
"time"
"gorm.io/gen"
"gorm.io/gorm"
"time"
)
var db *gorm.DB
@ -31,7 +32,7 @@ func GenerateAllModel() []any {
BanIP{},
Config{},
Passkey{},
SiteCategory{},
EnvGroup{},
}
}

View file

@ -2,9 +2,9 @@ package model
type Site struct {
Model
Path string `json:"path"`
Advanced bool `json:"advanced"`
SiteCategoryID uint64 `json:"site_category_id"`
SiteCategory *SiteCategory `json:"site_category,omitempty"`
SyncNodeIDs []uint64 `json:"sync_node_ids" gorm:"serializer:json"`
Path string `json:"path" gorm:"uniqueIndex"`
Advanced bool `json:"advanced"`
EnvGroupID uint64 `json:"env_group_id"`
EnvGroup *EnvGroup `json:"env_group,omitempty"`
SyncNodeIDs []uint64 `json:"sync_node_ids" gorm:"serializer:json"`
}

View file

@ -2,7 +2,9 @@ package model
type Stream struct {
Model
Path string `json:"path"`
Advanced bool `json:"advanced"`
SyncNodeIDs []uint64 `json:"sync_node_ids" gorm:"serializer:json"`
Path string `json:"path" gorm:"uniqueIndex"`
Advanced bool `json:"advanced"`
EnvGroupID uint64 `json:"env_group_id"`
EnvGroup *EnvGroup `json:"env_group,omitempty"`
SyncNodeIDs []uint64 `json:"sync_node_ids" gorm:"serializer:json"`
}

View file

@ -41,7 +41,7 @@ type AuthToken struct {
}
func (u *User) TableName() string {
return "auths"
return "users"
}
func (u *User) AfterFind(_ *gorm.DB) error {