modified: main_dc/yalarba/api_yal/internal/database/psql_db.go
modified: main_dc/yalarba/api_yal/internal/models/account.go renamed: main_dc/yalarba/api_yal/internal/models/Object.go -> "main_dc/yalarba/api_yal/internal/models/\320\276bject.go" add Onwer Account ass foregn key into Object
This commit is contained in:
@@ -43,6 +43,7 @@ func autoMigrate(db *gorm.DB) error {
|
||||
models := []interface{}{
|
||||
&models.Account{},
|
||||
&models.UpdateHistory{},
|
||||
&models.Object{},
|
||||
}
|
||||
|
||||
for _, model := range models {
|
||||
|
||||
@@ -26,4 +26,8 @@ type Account struct {
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
IsVerified bool `gorm:"default:false" json:"is_verified"`
|
||||
Role string `gorm:"default:user" json:"role"` // user, admin, moderator
|
||||
|
||||
|
||||
// Связь: один Account имеет много Objects
|
||||
Objects []Оbject `json:"objects"` // Обратная связь
|
||||
}
|
||||
|
||||
+3
@@ -6,6 +6,9 @@ type Object struct {
|
||||
/*ID, CreatedAt, UpdatedAt, DeletedAt (Update's history)*/
|
||||
Base Base `gorm:"embedded"`
|
||||
|
||||
// owner account ID
|
||||
Owner Account `gorm:"foreignKey:OwnerID" json:"owner"`
|
||||
|
||||
// Основная информация
|
||||
Short_Name string `gorm:"not null" json:"name"`
|
||||
Long_Name string `json:"long_name"`
|
||||
Reference in New Issue
Block a user