fix(db): store CreatedAt/UpdatedAt in milliseconds

GORM's autoCreateTime/autoUpdateTime tags default to Unix seconds on
int64 fields and overwrite the service-supplied UnixMilli value on
save. The frontend interprets these timestamps as JS Date inputs
(milliseconds), so created/updated columns rendered ~1970 dates. Adding
the :milli qualifier makes GORM match what the service code and UI
expect.
This commit is contained in:
MHSanaei 2026-05-23 14:36:51 +02:00
parent b5fb9e9fe0
commit 6a6a662a2e
No known key found for this signature in database
GPG key ID: 7E4060F2FBE5AB7A

View file

@ -144,7 +144,7 @@ type ApiToken struct {
Name string `json:"name" gorm:"uniqueIndex;not null"` Name string `json:"name" gorm:"uniqueIndex;not null"`
Token string `json:"token" gorm:"not null"` Token string `json:"token" gorm:"not null"`
Enabled bool `json:"enabled" gorm:"default:true"` Enabled bool `json:"enabled" gorm:"default:true"`
CreatedAt int64 `json:"createdAt" gorm:"autoCreateTime"` CreatedAt int64 `json:"createdAt" gorm:"autoCreateTime:milli"`
} }
// MarshalJSON emits settings, streamSettings, and sniffing as nested JSON // MarshalJSON emits settings, streamSettings, and sniffing as nested JSON
@ -275,8 +275,8 @@ type Node struct {
OnlineCount int `json:"onlineCount" gorm:"-"` OnlineCount int `json:"onlineCount" gorm:"-"`
DepletedCount int `json:"depletedCount" gorm:"-"` DepletedCount int `json:"depletedCount" gorm:"-"`
CreatedAt int64 `json:"createdAt" gorm:"autoCreateTime"` CreatedAt int64 `json:"createdAt" gorm:"autoCreateTime:milli"`
UpdatedAt int64 `json:"updatedAt" gorm:"autoUpdateTime"` UpdatedAt int64 `json:"updatedAt" gorm:"autoUpdateTime:milli"`
} }
type CustomGeoResource struct { type CustomGeoResource struct {
@ -287,8 +287,8 @@ type CustomGeoResource struct {
LocalPath string `json:"localPath" gorm:"column:local_path"` LocalPath string `json:"localPath" gorm:"column:local_path"`
LastUpdatedAt int64 `json:"lastUpdatedAt" gorm:"default:0;column:last_updated_at"` LastUpdatedAt int64 `json:"lastUpdatedAt" gorm:"default:0;column:last_updated_at"`
LastModified string `json:"lastModified" gorm:"column:last_modified"` LastModified string `json:"lastModified" gorm:"column:last_modified"`
CreatedAt int64 `json:"createdAt" gorm:"autoCreateTime;column:created_at"` CreatedAt int64 `json:"createdAt" gorm:"autoCreateTime:milli;column:created_at"`
UpdatedAt int64 `json:"updatedAt" gorm:"autoUpdateTime;column:updated_at"` UpdatedAt int64 `json:"updatedAt" gorm:"autoUpdateTime:milli;column:updated_at"`
} }
type ClientReverse struct { type ClientReverse struct {
@ -333,8 +333,8 @@ type ClientRecord struct {
TgID int64 `json:"tgId" gorm:"column:tg_id"` TgID int64 `json:"tgId" gorm:"column:tg_id"`
Comment string `json:"comment"` Comment string `json:"comment"`
Reset int `json:"reset" gorm:"default:0"` Reset int `json:"reset" gorm:"default:0"`
CreatedAt int64 `json:"createdAt" gorm:"autoCreateTime"` CreatedAt int64 `json:"createdAt" gorm:"autoCreateTime:milli"`
UpdatedAt int64 `json:"updatedAt" gorm:"autoUpdateTime"` UpdatedAt int64 `json:"updatedAt" gorm:"autoUpdateTime:milli"`
} }
func (ClientRecord) TableName() string { return "clients" } func (ClientRecord) TableName() string { return "clients" }
@ -374,7 +374,7 @@ type ClientInbound struct {
ClientId int `json:"clientId" gorm:"primaryKey;column:client_id;index"` ClientId int `json:"clientId" gorm:"primaryKey;column:client_id;index"`
InboundId int `json:"inboundId" gorm:"primaryKey;column:inbound_id;index"` InboundId int `json:"inboundId" gorm:"primaryKey;column:inbound_id;index"`
FlowOverride string `json:"flowOverride" gorm:"column:flow_override"` FlowOverride string `json:"flowOverride" gorm:"column:flow_override"`
CreatedAt int64 `json:"createdAt" gorm:"autoCreateTime"` CreatedAt int64 `json:"createdAt" gorm:"autoCreateTime:milli"`
} }
func (ClientInbound) TableName() string { return "client_inbounds" } func (ClientInbound) TableName() string { return "client_inbounds" }