diff --git a/sdks/storage/models.go b/sdks/storage/models.go index 3dff0a0..d5c1e79 100644 --- a/sdks/storage/models.go +++ b/sdks/storage/models.go @@ -168,10 +168,10 @@ const ( ) type Package struct { - PackageID PackageID `gorm:"column:PackageID; primaryKey; autoIncrement" json:"packageID"` - Name string `gorm:"column:Name" json:"name"` - BucketID BucketID `gorm:"column:BucketID" json:"bucketID"` - State string `gorm:"column:State" json:"state"` + PackageID PackageID `gorm:"column:PackageID; primaryKey; type:bigint; autoIncrement" json:"packageID"` + Name string `gorm:"column:Name; type:varchar(255); not null" json:"name"` + BucketID BucketID `gorm:"column:BucketID; type:bigint; not null" json:"bucketID"` + State string `gorm:"column:State; type:varchar(255); not null" json:"state"` } func (Package) TableName() string { @@ -179,14 +179,14 @@ func (Package) TableName() string { } type Object struct { - ObjectID ObjectID `gorm:"column:ObjectID; primaryKey; autoIncrement" json:"objectID"` - PackageID PackageID `gorm:"column:PackageID; index: PackagePath, unique;" json:"packageID"` - Path string `gorm:"column:Path; index: PackagePath, unique;" json:"path"` - Size int64 `gorm:"column:Size" json:"size,string"` - FileHash FileHash `gorm:"column:FileHash" json:"fileHash"` - Redundancy Redundancy `gorm:"column:Redundancy; type: json; serializer:union" json:"redundancy"` - CreateTime time.Time `gorm:"column:CreateTime" json:"createTime"` - UpdateTime time.Time `gorm:"column:UpdateTime" json:"updateTime"` + ObjectID ObjectID `json:"objectID" gorm:"column:ObjectID; primaryKey; type:bigint; autoIncrement" ` + PackageID PackageID `json:"packageID" gorm:"column:PackageID; type:bigint; not null"` + Path string `json:"path" gorm:"column:Path; type:varchar(1024); not null"` + Size int64 `json:"size,string" gorm:"column:Size; type:bigint; not null"` + FileHash FileHash `json:"fileHash" gorm:"column:FileHash; type:char(64); not null"` + Redundancy Redundancy `json:"redundancy" gorm:"column:Redundancy; type: json; serializer:union"` + CreateTime time.Time `json:"createTime" gorm:"column:CreateTime; type:datetime; not null"` + UpdateTime time.Time `json:"updateTime" gorm:"column:UpdateTime; type:datetime; not null"` } func (Object) TableName() string { @@ -194,12 +194,12 @@ func (Object) TableName() string { } type Node struct { - NodeID NodeID `gorm:"column:NodeID; primaryKey; autoIncrement" json:"nodeID"` - Name string `gorm:"column:Name;type:varchar(255); not null" json:"name"` + NodeID NodeID `gorm:"column:NodeID; primaryKey; type:bigint; autoIncrement" json:"nodeID"` + Name string `gorm:"column:Name; type:varchar(255); not null" json:"name"` Address NodeAddressInfo `gorm:"column:Address; type:json; serializer:union" json:"address"` - LocationID LocationID `gorm:"column:LocationID;" json:"locationID"` - State string `gorm:"column:State;" json:"state"` - LastReportTime *time.Time `gorm:"column:LastReportTime;" json:"lastReportTime"` + LocationID LocationID `gorm:"column:LocationID; type:bigint; not null" json:"locationID"` + State string `gorm:"column:State; type:varchar(255); not null" json:"state"` + LastReportTime *time.Time `gorm:"column:LastReportTime; type:datetime" json:"lastReportTime"` } func (Node) TableName() string { @@ -238,9 +238,9 @@ func (n Node) String() string { } type PinnedObject struct { - ObjectID ObjectID `gorm:"column:ObjectID; primaryKey" json:"objectID"` - StorageID StorageID `gorm:"column:StorageID; primaryKey" json:"storageID"` - CreateTime time.Time `gorm:"column:CreateTime" json:"createTime"` + ObjectID ObjectID `gorm:"column:ObjectID; primaryKey; type:bigint" json:"objectID"` + StorageID StorageID `gorm:"column:StorageID; primaryKey; type:bigint" json:"storageID"` + CreateTime time.Time `gorm:"column:CreateTime; type:datetime; not null" json:"createTime"` } func (PinnedObject) TableName() string { @@ -248,9 +248,9 @@ func (PinnedObject) TableName() string { } type Bucket struct { - BucketID BucketID `gorm:"column:BucketID; primaryKey; autoIncrement" json:"bucketID"` - Name string `gorm:"column:Name" json:"name"` - CreatorID UserID `gorm:"column:CreatorID" json:"creatorID"` + BucketID BucketID `gorm:"column:BucketID; primaryKey; type:bigint; autoIncrement" json:"bucketID"` + Name string `gorm:"column:Name; type:varchar(255); not null" json:"name"` + CreatorID UserID `gorm:"column:CreatorID; type:bigint; not null" json:"creatorID"` } func (Bucket) TableName() string { @@ -258,10 +258,10 @@ func (Bucket) TableName() string { } type NodeConnectivity struct { - FromNodeID NodeID `gorm:"column:FromNodeID; primaryKey" json:"fromNodeID"` - ToNodeID NodeID `gorm:"column:ToNodeID; primaryKey" json:"ToNodeID"` - Delay *float32 `gorm:"column:Delay" json:"delay"` - TestTime time.Time `gorm:"column:TestTime" json:"testTime"` + FromNodeID NodeID `gorm:"column:FromNodeID; primaryKey; type:bigint" json:"fromNodeID"` + ToNodeID NodeID `gorm:"column:ToNodeID; primaryKey; type:bigint" json:"ToNodeID"` + Delay *float32 `gorm:"column:Delay; type:float" json:"delay"` + TestTime time.Time `gorm:"column:TestTime; type:datetime" json:"testTime"` } func (NodeConnectivity) TableName() string { diff --git a/sdks/storage/shard_storage.go b/sdks/storage/shard_storage.go index 528536d..c5e6670 100644 --- a/sdks/storage/shard_storage.go +++ b/sdks/storage/shard_storage.go @@ -19,9 +19,9 @@ var _ = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[ShardSt )), "type") type ShardStorage struct { - StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey"` + StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey; type:bigint"` // Shard存储空间在存储服务的目录 - Root string `json:"root" gorm:"column:Root; not null"` + Root string `json:"root" gorm:"column:Root; type:varchar(1024); not null"` // ShardStore配置数据 Config ShardStoreConfig `json:"config" gorm:"column:Config; type:json; not null; serializer:union"` } diff --git a/sdks/storage/storage.go b/sdks/storage/storage.go index 72a150c..da0180e 100644 --- a/sdks/storage/storage.go +++ b/sdks/storage/storage.go @@ -31,10 +31,10 @@ func (a *LocalStorageAddress) String() string { } type Storage struct { - StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey; autoIncrement;"` - Name string `json:"name" gorm:"column:Name; not null"` + StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey; type:bigint; autoIncrement;"` + Name string `json:"name" gorm:"column:Name; type:varchar(256); not null"` // 完全管理此存储服务的Hub的ID - MasterHub NodeID `json:"masterHub" gorm:"column:MasterHub; not null"` + MasterHub NodeID `json:"masterHub" gorm:"column:MasterHub; type:bigint; not null"` // 存储服务的地址,包含鉴权所需数据 Address StorageAddress `json:"address" gorm:"column:Address; type:json; not null; serializer:union"` // 存储服务拥有的特别功能 @@ -51,11 +51,11 @@ func (s *Storage) String() string { // 共享存储服务的配置数据 type SharedStorage struct { - StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey"` + StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey; type:bigint"` // 调度文件时保存文件的根路径 - LoadBase string `json:"loadBase" gorm:"column:LoadBase; not null"` + LoadBase string `json:"loadBase" gorm:"column:LoadBase; type:varchar(1024); not null"` // 回源数据时数据存放位置的根路径 - DataReturnBase string `json:"dataReturnBase" gorm:"column:DataReturnBase; not null"` + DataReturnBase string `json:"dataReturnBase" gorm:"column:DataReturnBase; type:varchar(1024); not null"` } func (SharedStorage) TableName() string {