From 77a578528fb1281374dd55b57f2108de7af303e3 Mon Sep 17 00:00:00 2001 From: "kim (grufwub)" Date: Thu, 26 Aug 2021 20:11:15 +0100 Subject: [PATCH] ensure ,notnull,nullzero on all columns with default values Signed-off-by: kim (grufwub) --- internal/gtsmodel/account.go | 10 +++++----- internal/gtsmodel/emoji.go | 6 +++--- internal/gtsmodel/follow.go | 2 +- internal/gtsmodel/followrequest.go | 2 +- internal/gtsmodel/instance.go | 2 +- internal/gtsmodel/mediaattachment.go | 4 ++-- internal/gtsmodel/status.go | 8 ++++---- internal/gtsmodel/tag.go | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/internal/gtsmodel/account.go b/internal/gtsmodel/account.go index a59746be5..3eff69582 100644 --- a/internal/gtsmodel/account.go +++ b/internal/gtsmodel/account.go @@ -78,15 +78,15 @@ type Account struct { */ // Does this account need an approval for new followers? - Locked bool `bun:",default:true"` + Locked bool `bun:",nullzero,notnull,default:true"` // Should this account be shown in the instance's profile directory? - Discoverable bool `bun:",default:false"` + Discoverable bool `bun:",nullzero,notnull,default:false"` // Default post privacy for this account - Privacy Visibility `bun:",default:'public'"` + Privacy Visibility `bun:",nullzero,notnull,default:'public'"` // Set posts from this account to sensitive by default? - Sensitive bool `bun:",default:false"` + Sensitive bool `bun:",nullzero,notnull,default:false"` // What language does this account post in? - Language string `bun:",default:'en'"` + Language string `bun:",nullzero,notnull,default:'en'"` /* ACTIVITYPUB THINGS diff --git a/internal/gtsmodel/emoji.go b/internal/gtsmodel/emoji.go index 9723f0790..971254d15 100644 --- a/internal/gtsmodel/emoji.go +++ b/internal/gtsmodel/emoji.go @@ -28,7 +28,7 @@ type Emoji struct { // eg., 'blob_hug' 'purple_heart' Must be unique with domain. Shortcode string `bun:",notnull,unique:shortcodedomain"` // Origin domain of this emoji, eg 'example.org', 'queer.party'. empty string for local emojis. - Domain string `bun:",notnull,default:'',unique:shortcodedomain"` + Domain string `bun:",nullzero,notnull,default:'',unique:shortcodedomain"` // When was this emoji created. Must be unique with shortcode. CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"` // When was this emoji updated @@ -67,11 +67,11 @@ type Emoji struct { // When was the emoji image last updated? ImageUpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"` // Has a moderation action disabled this emoji from being shown? - Disabled bool `bun:",notnull,default:false"` + Disabled bool `bun:",nullzero,notnull,default:false"` // ActivityStreams uri of this emoji. Something like 'https://example.org/emojis/1234' URI string `bun:",notnull,unique"` // Is this emoji visible in the admin emoji picker? - VisibleInPicker bool `bun:",notnull,default:true"` + VisibleInPicker bool `bun:",nullzero,notnull,default:true"` // In which emoji category is this emoji visible? CategoryID string `bun:"type:CHAR(26),nullzero"` } diff --git a/internal/gtsmodel/follow.go b/internal/gtsmodel/follow.go index 1e1095af9..0ad276345 100644 --- a/internal/gtsmodel/follow.go +++ b/internal/gtsmodel/follow.go @@ -35,7 +35,7 @@ type Follow struct { TargetAccountID string `bun:"type:CHAR(26),unique:srctarget,notnull"` TargetAccount *Account `bun:"rel:belongs-to"` // Does this follow also want to see reblogs and not just posts? - ShowReblogs bool `bun:"default:true"` + ShowReblogs bool `bun:",nullzero,notnull,default:true"` // What is the activitypub URI of this follow? URI string `bun:",unique,nullzero"` // does the following account want to be notified when the followed account posts? diff --git a/internal/gtsmodel/followrequest.go b/internal/gtsmodel/followrequest.go index 5a6cb5e02..ce0c98a96 100644 --- a/internal/gtsmodel/followrequest.go +++ b/internal/gtsmodel/followrequest.go @@ -35,7 +35,7 @@ type FollowRequest struct { TargetAccountID string `bun:"type:CHAR(26),unique:frsrctarget,notnull"` TargetAccount *Account `bun:"rel:belongs-to"` // Does this follow also want to see reblogs and not just posts? - ShowReblogs bool `bun:"default:true"` + ShowReblogs bool `bun:",nullzero,notnull,default:true"` // What is the activitypub URI of this follow request? URI string `bun:",unique,nullzero"` // does the following account want to be notified when the followed account posts? diff --git a/internal/gtsmodel/instance.go b/internal/gtsmodel/instance.go index ca2857b95..6ddb33617 100644 --- a/internal/gtsmodel/instance.go +++ b/internal/gtsmodel/instance.go @@ -35,7 +35,7 @@ type Instance struct { ContactAccountID string `bun:"type:CHAR(26),nullzero"` ContactAccount *Account `bun:"rel:belongs-to"` // Reputation score of this instance - Reputation int64 `bun:",notnull,default:0"` + Reputation int64 `bun:",nullzero,notnull,default:0"` // Version of the software used on this instance Version string `bun:",nullzero"` } diff --git a/internal/gtsmodel/mediaattachment.go b/internal/gtsmodel/mediaattachment.go index 2acf6a6fc..674ae1328 100644 --- a/internal/gtsmodel/mediaattachment.go +++ b/internal/gtsmodel/mediaattachment.go @@ -71,7 +71,7 @@ type File struct { // What is the size of the file in bytes. FileSize int // When was the file last updated. - UpdatedAt time.Time `bun:",notnull,default:current_timestamp"` + UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"` } // Thumbnail refers to a small image thumbnail derived from a larger image, video, or audio file. @@ -83,7 +83,7 @@ type Thumbnail struct { // What is the size of the file in bytes FileSize int // When was the file last updated - UpdatedAt time.Time `bun:",notnull,default:current_timestamp"` + UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"` // What is the URL of the thumbnail on the local server URL string `bun:",nullzero"` // What is the remote URL of the thumbnail (empty for local media) diff --git a/internal/gtsmodel/status.go b/internal/gtsmodel/status.go index 1997ad5df..47df86cad 100644 --- a/internal/gtsmodel/status.go +++ b/internal/gtsmodel/status.go @@ -138,11 +138,11 @@ const ( // If DIRECT is selected, boostable will be FALSE, and all other flags will be TRUE. type VisibilityAdvanced struct { // This status will be federated beyond the local timeline(s) - Federated bool `bun:"default:true"` + Federated bool `bun:",nullzero,notnull,default:true"` // This status can be boosted/reblogged - Boostable bool `bun:"default:true"` + Boostable bool `bun:",nullzero,notnull,default:true"` // This status can be replied to - Replyable bool `bun:"default:true"` + Replyable bool `bun:",nullzero,notnull,default:true"` // This status can be liked/faved - Likeable bool `bun:"default:true"` + Likeable bool `bun:",nullzero,notnull,default:true"` } diff --git a/internal/gtsmodel/tag.go b/internal/gtsmodel/tag.go index d4be0b66c..9933c0234 100644 --- a/internal/gtsmodel/tag.go +++ b/internal/gtsmodel/tag.go @@ -35,9 +35,9 @@ type Tag struct { // when was this tag last updated UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"` // can our instance users use this tag? - Useable bool `bun:",notnull,default:true"` + Useable bool `bun:",nullzero,notnull,default:true"` // can our instance users look up this tag? - Listable bool `bun:",notnull,default:true"` + Listable bool `bun:",nullzero,notnull,default:true"` // when was this tag last used? LastStatusAt time.Time `bun:",nullzero"` }