From a12148671a38b058932256d574141b3c604a0f63 Mon Sep 17 00:00:00 2001 From: lishuang Date: Sat, 5 Aug 2023 01:19:50 +0800 Subject: [PATCH] feat: fix the bug for sqlite. --- code/rest/dashboard_model.go | 20 ++++++++++---------- code/rest/download_token_model.go | 2 +- code/rest/image_cache_model.go | 2 +- code/rest/matter_model.go | 10 +++++----- code/rest/share_model.go | 2 +- code/rest/space_member_model.go | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/code/rest/dashboard_model.go b/code/rest/dashboard_model.go index e500b37..3e0dd53 100644 --- a/code/rest/dashboard_model.go +++ b/code/rest/dashboard_model.go @@ -10,16 +10,16 @@ type Dashboard struct { Sort int64 `json:"sort" gorm:"type:bigint(20) not null"` UpdateTime time.Time `json:"updateTime" gorm:"type:timestamp not null;default:CURRENT_TIMESTAMP"` CreateTime time.Time `json:"createTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"` - InvokeNum int64 `json:"invokeNum" gorm:"type:bigint(20) not null"` //api invoke num. - TotalInvokeNum int64 `json:"totalInvokeNum" gorm:"type:bigint(20) not null;default:0"` //total invoke num up to now. - Uv int64 `json:"uv" gorm:"type:bigint(20) not null;default:0"` //today's uv - TotalUv int64 `json:"totalUv" gorm:"type:bigint(20) not null;default:0"` //total uv - MatterNum int64 `json:"matterNum" gorm:"type:bigint(20) not null;default:0"` //file's num - TotalMatterNum int64 `json:"totalMatterNum" gorm:"type:bigint(20) not null;default:0"` //file's total number - FileSize int64 `json:"fileSize" gorm:"type:bigint(20) not null;default:0"` //today's file size - TotalFileSize int64 `json:"totalFileSize" gorm:"type:bigint(20) not null;default:0"` //total file's size - AvgCost int64 `json:"avgCost" gorm:"type:bigint(20) not null;default:0"` //api time cost in ms - Dt string `json:"dt" gorm:"type:varchar(45) not null;index:idx_dt"` //date. index should unique globally. + InvokeNum int64 `json:"invokeNum" gorm:"type:bigint(20) not null"` //api invoke num. + TotalInvokeNum int64 `json:"totalInvokeNum" gorm:"type:bigint(20) not null;default:0"` //total invoke num up to now. + Uv int64 `json:"uv" gorm:"type:bigint(20) not null;default:0"` //today's uv + TotalUv int64 `json:"totalUv" gorm:"type:bigint(20) not null;default:0"` //total uv + MatterNum int64 `json:"matterNum" gorm:"type:bigint(20) not null;default:0"` //file's num + TotalMatterNum int64 `json:"totalMatterNum" gorm:"type:bigint(20) not null;default:0"` //file's total number + FileSize int64 `json:"fileSize" gorm:"type:bigint(20) not null;default:0"` //today's file size + TotalFileSize int64 `json:"totalFileSize" gorm:"type:bigint(20) not null;default:0"` //total file's size + AvgCost int64 `json:"avgCost" gorm:"type:bigint(20) not null;default:0"` //api time cost in ms + Dt string `json:"dt" gorm:"type:varchar(45) not null;index:idx_dashboard_dt"` //date. index should unique globally for sqlite. } /** diff --git a/code/rest/download_token_model.go b/code/rest/download_token_model.go index e9081f1..043f24d 100644 --- a/code/rest/download_token_model.go +++ b/code/rest/download_token_model.go @@ -10,7 +10,7 @@ type DownloadToken struct { UpdateTime time.Time `json:"updateTime" gorm:"type:timestamp not null;default:CURRENT_TIMESTAMP"` CreateTime time.Time `json:"createTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"` UserUuid string `json:"userUuid" gorm:"type:char(36) not null"` - MatterUuid string `json:"matterUuid" gorm:"type:char(36) not null;index:idx_mu"` //index should unique globally. + MatterUuid string `json:"matterUuid" gorm:"type:char(36) not null;index:idx_download_token_mu"` //index should unique globally for sqlite ExpireTime time.Time `json:"expireTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"` Ip string `json:"ip" gorm:"type:varchar(128) not null"` } diff --git a/code/rest/image_cache_model.go b/code/rest/image_cache_model.go index 58fd54c..1c43884 100644 --- a/code/rest/image_cache_model.go +++ b/code/rest/image_cache_model.go @@ -13,7 +13,7 @@ type ImageCache struct { Name string `json:"name" gorm:"type:varchar(255) not null"` UserUuid string `json:"userUuid" gorm:"type:char(36)"` Username string `json:"username" gorm:"type:varchar(45) not null"` - MatterUuid string `json:"matterUuid" gorm:"type:char(36);index:idx_mu"` //index should unique globally. + MatterUuid string `json:"matterUuid" gorm:"type:char(36);index:idx_image_cache_mu"` //index should unique globally. MatterName string `json:"matterName" gorm:"type:varchar(255) not null"` Mode string `json:"mode" gorm:"type:varchar(512)"` Md5 string `json:"md5" gorm:"type:varchar(45)"` diff --git a/code/rest/matter_model.go b/code/rest/matter_model.go index 20d3a05..7bdb629 100644 --- a/code/rest/matter_model.go +++ b/code/rest/matter_model.go @@ -34,8 +34,8 @@ type Matter struct { Sort int64 `json:"sort" gorm:"type:bigint(20) not null"` UpdateTime time.Time `json:"updateTime" gorm:"type:timestamp not null;default:CURRENT_TIMESTAMP"` CreateTime time.Time `json:"createTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"` - Puuid string `json:"puuid" gorm:"type:char(36);index:idx_puuid"` //index should unique globally. - UserUuid string `json:"userUuid" gorm:"type:char(36);index:idx_uu"` + Puuid string `json:"puuid" gorm:"type:char(36);index:idx_matter_puuid"` //index should unique globally for sqlite. + UserUuid string `json:"userUuid" gorm:"type:char(36);index:idx_matter_uu"` //TODO: check field usage. SpaceName string `json:"space_name" gorm:"type:varchar(45) not null"` Dir bool `json:"dir" gorm:"type:tinyint(1) not null;default:0"` @@ -47,9 +47,9 @@ type Matter struct { Times int64 `json:"times" gorm:"type:bigint(20) not null;default:0"` Prop string `json:"prop" gorm:"type:varchar(1024) not null;default:'{}'"` VisitTime time.Time `json:"visitTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"` - Deleted bool `json:"deleted" gorm:"type:tinyint(1) not null;index:idx_del;default:0"` - DeleteTime time.Time `json:"deleteTime" gorm:"type:timestamp not null;index:idx_delt;default:'2018-01-01 00:00:00'"` - SpaceUuid string `json:"spaceUuid" gorm:"type:char(36) not null;index:idx_space_uuid"` + Deleted bool `json:"deleted" gorm:"type:tinyint(1) not null;index:idx_matter_del;default:0"` + DeleteTime time.Time `json:"deleteTime" gorm:"type:timestamp not null;index:idx_matter_delt;default:'2018-01-01 00:00:00'"` + SpaceUuid string `json:"spaceUuid" gorm:"type:char(36) not null;index:idx_matter_space_uuid"` User *User `json:"user" gorm:"-"` Parent *Matter `json:"parent" gorm:"-"` Children []*Matter `json:"-" gorm:"-"` diff --git a/code/rest/share_model.go b/code/rest/share_model.go index aa23737..2f97631 100644 --- a/code/rest/share_model.go +++ b/code/rest/share_model.go @@ -33,7 +33,7 @@ type Share struct { Code string `json:"code" gorm:"type:varchar(45) not null"` ExpireInfinity bool `json:"expireInfinity" gorm:"type:tinyint(1) not null;default:0"` ExpireTime time.Time `json:"expireTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"` - SpaceUuid string `json:"spaceUuid" gorm:"type:char(36) not null;index:idx_space_uuid"` + SpaceUuid string `json:"spaceUuid" gorm:"type:char(36) not null;index:idx_share_space_uuid"` DirMatter *Matter `json:"dirMatter" gorm:"-"` Matters []*Matter `json:"matters" gorm:"-"` } diff --git a/code/rest/space_member_model.go b/code/rest/space_member_model.go index 37cc6a0..08d954e 100644 --- a/code/rest/space_member_model.go +++ b/code/rest/space_member_model.go @@ -23,8 +23,8 @@ type SpaceMember struct { Sort int64 `json:"sort" gorm:"type:bigint(20) not null"` UpdateTime time.Time `json:"updateTime" gorm:"type:timestamp not null;default:CURRENT_TIMESTAMP"` CreateTime time.Time `json:"createTime" gorm:"type:timestamp not null;default:'2018-01-01 00:00:00'"` - SpaceUuid string `json:"spaceUuid" gorm:"type:char(36);index:idx_space_uuid"` - UserUuid string `json:"userUuid" gorm:"type:char(36);index:idx_user_uuid"` + SpaceUuid string `json:"spaceUuid" gorm:"type:char(36);index:idx_space_member_su"` + UserUuid string `json:"userUuid" gorm:"type:char(36);index:idx_space_member_uu"` Role string `json:"role" gorm:"type:varchar(45)"` User *User `json:"user" gorm:"-"` }