From bb862b54bd2399bb1dc31a643db266f5c03a00b2 Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 27 Nov 2024 16:02:28 +0000 Subject: [PATCH] fix new statusedits sql --- internal/config/defaults.go | 1 + internal/db/bundb/migrations/20241113152126_add_status_edits.go | 1 - .../bundb/migrations/20241113152126_add_status_edits/status.go | 2 +- .../migrations/20241113152126_add_status_edits/statusedit.go | 2 +- internal/db/bundb/migrations/util.go | 2 +- internal/gtsmodel/status.go | 2 +- internal/gtsmodel/statusedit.go | 2 +- 7 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/config/defaults.go b/internal/config/defaults.go index 9b45002d0..f77c5c456 100644 --- a/internal/config/defaults.go +++ b/internal/config/defaults.go @@ -199,6 +199,7 @@ var Defaults = Configuration{ StatusMemRatio: 5, StatusBookmarkMemRatio: 0.5, StatusBookmarkIDsMemRatio: 2, + StatusEditMemRatio: 2, StatusFaveMemRatio: 2, StatusFaveIDsMemRatio: 3, TagMemRatio: 2, diff --git a/internal/db/bundb/migrations/20241113152126_add_status_edits.go b/internal/db/bundb/migrations/20241113152126_add_status_edits.go index 636c34620..aa0b0d4b9 100644 --- a/internal/db/bundb/migrations/20241113152126_add_status_edits.go +++ b/internal/db/bundb/migrations/20241113152126_add_status_edits.go @@ -39,7 +39,6 @@ func init() { // Add EditIDs column to Status table. _, err = tx.NewAddColumn(). - IfNotExists(). Model((*gtsmodel.Status)(nil)). ColumnExpr(colDef). Exec(ctx) diff --git a/internal/db/bundb/migrations/20241113152126_add_status_edits/status.go b/internal/db/bundb/migrations/20241113152126_add_status_edits/status.go index 684a01c6e..1b7d93f70 100644 --- a/internal/db/bundb/migrations/20241113152126_add_status_edits/status.go +++ b/internal/db/bundb/migrations/20241113152126_add_status_edits/status.go @@ -56,7 +56,7 @@ type Status struct { BoostOf *Status `bun:"-"` // status that corresponds to boostOfID BoostOfAccount *gtsmodel.Account `bun:"rel:belongs-to"` // account that corresponds to boostOfAccountID ThreadID string `bun:"type:CHAR(26),nullzero"` // id of the thread to which this status belongs; only set for remote statuses if a local account is involved at some point in the thread, otherwise null - EditIDs []string `bun:",array"` // + EditIDs []string `bun:"edits,array"` // Edits []*StatusEdit `bun:"-"` // PollID string `bun:"type:CHAR(26),nullzero"` // Poll *gtsmodel.Poll `bun:"-"` // diff --git a/internal/db/bundb/migrations/20241113152126_add_status_edits/statusedit.go b/internal/db/bundb/migrations/20241113152126_add_status_edits/statusedit.go index 6d8f7c45d..e1f989b2f 100644 --- a/internal/db/bundb/migrations/20241113152126_add_status_edits/statusedit.go +++ b/internal/db/bundb/migrations/20241113152126_add_status_edits/statusedit.go @@ -37,7 +37,7 @@ type StatusEdit struct { Text string `bun:""` // Original status text, without formatting, at time of edit. Language string `bun:",nullzero"` // Status language at time of edit. Sensitive *bool `bun:",nullzero,notnull,default:false"` // Status sensitive flag at time of edit. - AttachmentIDs []string `bun:",array"` // Database IDs of media attachments associated with status at time of edit. + AttachmentIDs []string `bun:"attachments,array"` // Database IDs of media attachments associated with status at time of edit. Attachments []*gtsmodel.MediaAttachment `bun:"-"` // Media attachments relating to .AttachmentIDs field (not always populated). PollOptions []string `bun:",array"` // Poll options of status at time of edit, only set if status contains a poll. PollVotes []int `bun:",array"` // Poll vote count at time of status edit, only set if poll votes were reset. diff --git a/internal/db/bundb/migrations/util.go b/internal/db/bundb/migrations/util.go index b917c566b..edf7c1d05 100644 --- a/internal/db/bundb/migrations/util.go +++ b/internal/db/bundb/migrations/util.go @@ -171,7 +171,7 @@ func getBunColumnDef(db bun.IDB, rtype reflect.Type, fieldName string) (string, } else { buf = append(buf, sqltype.VarChar...) } - buf = append(buf, sqltype.VarChar+"("...) + buf = append(buf, "("...) buf = strconv.AppendInt(buf, int64(d.DefaultVarcharLen()), 10) buf = append(buf, ")"...) } diff --git a/internal/gtsmodel/status.go b/internal/gtsmodel/status.go index 3beba68d5..2de182007 100644 --- a/internal/gtsmodel/status.go +++ b/internal/gtsmodel/status.go @@ -57,7 +57,7 @@ type Status struct { BoostOf *Status `bun:"-"` // status that corresponds to boostOfID BoostOfAccount *Account `bun:"rel:belongs-to"` // account that corresponds to boostOfAccountID ThreadID string `bun:"type:CHAR(26),nullzero"` // id of the thread to which this status belongs; only set for remote statuses if a local account is involved at some point in the thread, otherwise null - EditIDs []string `bun:",array"` // + EditIDs []string `bun:"edits,array"` // Edits []*StatusEdit `bun:"-"` // PollID string `bun:"type:CHAR(26),nullzero"` // Poll *Poll `bun:"-"` // diff --git a/internal/gtsmodel/statusedit.go b/internal/gtsmodel/statusedit.go index a87ed736d..518b1f0c6 100644 --- a/internal/gtsmodel/statusedit.go +++ b/internal/gtsmodel/statusedit.go @@ -33,7 +33,7 @@ type StatusEdit struct { Text string `bun:""` // Original status text, without formatting, at time of edit. Language string `bun:",nullzero"` // Status language at time of edit. Sensitive *bool `bun:",nullzero,notnull,default:false"` // Status sensitive flag at time of edit. - AttachmentIDs []string `bun:",array"` // Database IDs of media attachments associated with status at time of edit. + AttachmentIDs []string `bun:"attachments,array"` // Database IDs of media attachments associated with status at time of edit. Attachments []*MediaAttachment `bun:"-"` // Media attachments relating to .AttachmentIDs field (not always populated). PollOptions []string `bun:",array"` // Poll options of status at time of edit, only set if status contains a poll. PollVotes []int `bun:",array"` // Poll vote count at time of status edit, only set if poll votes were reset.