fixed gorm shema for correct deletion and many2many relation beetween users and devices

This commit is contained in:
tdv
2025-09-15 16:59:35 +03:00
parent 673971deb8
commit aa60651610
5 changed files with 17 additions and 5 deletions

View File

@@ -0,0 +1,13 @@
package models
import "time"
type UserDevice struct {
UserID uint `gorm:"primaryKey;index;not null"`
DeviceGUID string `gorm:"primaryKey;size:64;index;not null"`
CreatedAt time.Time
// Optional FKs with cascade (you already have cascade constraints on both sides)
User User `gorm:"constraint:OnDelete:CASCADE;"`
Device Device `gorm:"constraint:OnDelete:CASCADE;foreignKey:DeviceGUID;references:GUID"`
}