summaryrefslogtreecommitdiff
path: root/internal/db/bundb/migrations/20250415111056_thread_all_statuses
diff options
context:
space:
mode:
Diffstat (limited to 'internal/db/bundb/migrations/20250415111056_thread_all_statuses')
-rw-r--r--internal/db/bundb/migrations/20250415111056_thread_all_statuses/new/status.go78
-rw-r--r--internal/db/bundb/migrations/20250415111056_thread_all_statuses/old/status.go8
-rw-r--r--internal/db/bundb/migrations/20250415111056_thread_all_statuses/util/utiltypes.go24
3 files changed, 70 insertions, 40 deletions
diff --git a/internal/db/bundb/migrations/20250415111056_thread_all_statuses/new/status.go b/internal/db/bundb/migrations/20250415111056_thread_all_statuses/new/status.go
index a03e93859..0f20bb7a4 100644
--- a/internal/db/bundb/migrations/20250415111056_thread_all_statuses/new/status.go
+++ b/internal/db/bundb/migrations/20250415111056_thread_all_statuses/new/status.go
@@ -23,45 +23,45 @@ import (
// Status represents a user-created 'post' or 'status' in the database, either remote or local
type Status struct {
- ID string `bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database
- CreatedAt time.Time `bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created
- EditedAt time.Time `bun:"type:timestamptz,nullzero"` // when this status was last edited (if set)
- FetchedAt time.Time `bun:"type:timestamptz,nullzero"` // when was item (remote) last fetched.
- PinnedAt time.Time `bun:"type:timestamptz,nullzero"` // Status was pinned by owning account at this time.
- URI string `bun:",unique,nullzero,notnull"` // activitypub URI of this status
- URL string `bun:",nullzero"` // web url for viewing this status
- Content string `bun:""` // Content HTML for this status.
- AttachmentIDs []string `bun:"attachments,array"` // Database IDs of any media attachments associated with this status
- TagIDs []string `bun:"tags,array"` // Database IDs of any tags used in this status
- MentionIDs []string `bun:"mentions,array"` // Database IDs of any mentions in this status
- EmojiIDs []string `bun:"emojis,array"` // Database IDs of any emojis used in this status
- Local *bool `bun:",nullzero,notnull,default:false"` // is this status from a local account?
- AccountID string `bun:"type:CHAR(26),nullzero,notnull"` // which account posted this status?
- AccountURI string `bun:",nullzero,notnull"` // activitypub uri of the owner of this status
- InReplyToID string `bun:"type:CHAR(26),nullzero"` // id of the status this status replies to
- InReplyToURI string `bun:",nullzero"` // activitypub uri of the status this status is a reply to
- InReplyToAccountID string `bun:"type:CHAR(26),nullzero"` // id of the account that this status replies to
- InReplyTo *Status `bun:"-"` // status corresponding to inReplyToID
- BoostOfID string `bun:"type:CHAR(26),nullzero"` // id of the status this status is a boost of
- BoostOfURI string `bun:"-"` // URI of the status this status is a boost of; field not inserted in the db, just for dereferencing purposes.
- BoostOfAccountID string `bun:"type:CHAR(26),nullzero"` // id of the account that owns the boosted status
- BoostOf *Status `bun:"-"` // status that corresponds to boostOfID
- ThreadID string `bun:"type:CHAR(26),nullzero,notnull,default:00000000000000000000000000"` // id of the thread to which this status belongs
- EditIDs []string `bun:"edits,array"` //
- PollID string `bun:"type:CHAR(26),nullzero"` //
- ContentWarning string `bun:",nullzero"` // Content warning HTML for this status.
- ContentWarningText string `bun:""` // Original text of the content warning without formatting
- Visibility Visibility `bun:",nullzero,notnull"` // visibility entry for this status
- Sensitive *bool `bun:",nullzero,notnull,default:false"` // mark the status as sensitive?
- Language string `bun:",nullzero"` // what language is this status written in?
- CreatedWithApplicationID string `bun:"type:CHAR(26),nullzero"` // Which application was used to create this status?
- ActivityStreamsType string `bun:",nullzero,notnull"` // What is the activitystreams type of this status? See: https://www.w3.org/TR/activitystreams-vocabulary/#object-types. Will probably almost always be Note but who knows!.
- Text string `bun:""` // Original text of the status without formatting
- ContentType StatusContentType `bun:",nullzero"` // Content type used to process the original text of the status
- Federated *bool `bun:",notnull"` // This status will be federated beyond the local timeline(s)
- PendingApproval *bool `bun:",nullzero,notnull,default:false"` // If true then status is a reply or boost wrapper that must be Approved by the reply-ee or boost-ee before being fully distributed.
- PreApproved bool `bun:"-"` // If true, then status is a reply to or boost wrapper of a status on our instance, has permission to do the interaction, and an Accept should be sent out for it immediately. Field not stored in the DB.
- ApprovedByURI string `bun:",nullzero"` // URI of an Accept Activity that approves the Announce or Create Activity that this status was/will be attached to.
+ ID string `bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database
+ CreatedAt time.Time `bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created
+ EditedAt time.Time `bun:"type:timestamptz,nullzero"` // when this status was last edited (if set)
+ FetchedAt time.Time `bun:"type:timestamptz,nullzero"` // when was item (remote) last fetched.
+ PinnedAt time.Time `bun:"type:timestamptz,nullzero"` // Status was pinned by owning account at this time.
+ URI string `bun:",unique,nullzero,notnull"` // activitypub URI of this status
+ URL string `bun:",nullzero"` // web url for viewing this status
+ Content string `bun:""` // Content HTML for this status.
+ AttachmentIDs []string `bun:"attachments,array"` // Database IDs of any media attachments associated with this status
+ TagIDs []string `bun:"tags,array"` // Database IDs of any tags used in this status
+ MentionIDs []string `bun:"mentions,array"` // Database IDs of any mentions in this status
+ EmojiIDs []string `bun:"emojis,array"` // Database IDs of any emojis used in this status
+ Local *bool `bun:",nullzero,notnull,default:false"` // is this status from a local account?
+ AccountID string `bun:"type:CHAR(26),nullzero,notnull"` // which account posted this status?
+ AccountURI string `bun:",nullzero,notnull"` // activitypub uri of the owner of this status
+ InReplyToID string `bun:"type:CHAR(26),nullzero"` // id of the status this status replies to
+ InReplyToURI string `bun:",nullzero"` // activitypub uri of the status this status is a reply to
+ InReplyToAccountID string `bun:"type:CHAR(26),nullzero"` // id of the account that this status replies to
+ InReplyTo *Status `bun:"-"` // status corresponding to inReplyToID
+ BoostOfID string `bun:"type:CHAR(26),nullzero"` // id of the status this status is a boost of
+ BoostOfURI string `bun:"-"` // URI of the status this status is a boost of; field not inserted in the db, just for dereferencing purposes.
+ BoostOfAccountID string `bun:"type:CHAR(26),nullzero"` // id of the account that owns the boosted status
+ BoostOf *Status `bun:"-"` // status that corresponds to boostOfID
+ ThreadID string `bun:"type:CHAR(26),nullzero,notnull,default:'00000000000000000000000000'"` // id of the thread to which this status belongs
+ EditIDs []string `bun:"edits,array"` //
+ PollID string `bun:"type:CHAR(26),nullzero"` //
+ ContentWarning string `bun:",nullzero"` // Content warning HTML for this status.
+ ContentWarningText string `bun:""` // Original text of the content warning without formatting
+ Visibility Visibility `bun:",nullzero,notnull"` // visibility entry for this status
+ Sensitive *bool `bun:",nullzero,notnull,default:false"` // mark the status as sensitive?
+ Language string `bun:",nullzero"` // what language is this status written in?
+ CreatedWithApplicationID string `bun:"type:CHAR(26),nullzero"` // Which application was used to create this status?
+ ActivityStreamsType string `bun:",nullzero,notnull"` // What is the activitystreams type of this status? See: https://www.w3.org/TR/activitystreams-vocabulary/#object-types. Will probably almost always be Note but who knows!.
+ Text string `bun:""` // Original text of the status without formatting
+ ContentType StatusContentType `bun:",nullzero"` // Content type used to process the original text of the status
+ Federated *bool `bun:",notnull"` // This status will be federated beyond the local timeline(s)
+ PendingApproval *bool `bun:",nullzero,notnull,default:false"` // If true then status is a reply or boost wrapper that must be Approved by the reply-ee or boost-ee before being fully distributed.
+ PreApproved bool `bun:"-"` // If true, then status is a reply to or boost wrapper of a status on our instance, has permission to do the interaction, and an Accept should be sent out for it immediately. Field not stored in the DB.
+ ApprovedByURI string `bun:",nullzero"` // URI of an Accept Activity that approves the Announce or Create Activity that this status was/will be attached to.
}
// enumType is the type we (at least, should) use
diff --git a/internal/db/bundb/migrations/20250415111056_thread_all_statuses/old/status.go b/internal/db/bundb/migrations/20250415111056_thread_all_statuses/old/status.go
index f33a2b29e..8cfce2e6b 100644
--- a/internal/db/bundb/migrations/20250415111056_thread_all_statuses/old/status.go
+++ b/internal/db/bundb/migrations/20250415111056_thread_all_statuses/old/status.go
@@ -21,7 +21,10 @@ import (
"time"
)
-// Status represents a user-created 'post' or 'status' in the database, either remote or local
+// Status represents a user-created 'post' or 'status' in the database, either remote or local.
+//
+// Note: this model differs from an exact representation of the old model at the time of migration,
+// as it includes the intermediate field "ThreadIDNew", which is only used during the migration.
type Status struct {
ID string `bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database
CreatedAt time.Time `bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"` // when was item created
@@ -60,6 +63,9 @@ type Status struct {
PendingApproval *bool `bun:",nullzero,notnull,default:false"` // If true then status is a reply or boost wrapper that must be Approved by the reply-ee or boost-ee before being fully distributed.
PreApproved bool `bun:"-"` // If true, then status is a reply to or boost wrapper of a status on our instance, has permission to do the interaction, and an Accept should be sent out for it immediately. Field not stored in the DB.
ApprovedByURI string `bun:",nullzero"` // URI of an Accept Activity that approves the Announce or Create Activity that this status was/will be attached to.
+
+ // This field is *only* used during the migration, it was not on the original status model.
+ ThreadIDNew string `bun:"type:CHAR(26),nullzero,notnull,default:'00000000000000000000000000'"`
}
// enumType is the type we (at least, should) use
diff --git a/internal/db/bundb/migrations/20250415111056_thread_all_statuses/util/utiltypes.go b/internal/db/bundb/migrations/20250415111056_thread_all_statuses/util/utiltypes.go
new file mode 100644
index 000000000..0acb18e21
--- /dev/null
+++ b/internal/db/bundb/migrations/20250415111056_thread_all_statuses/util/utiltypes.go
@@ -0,0 +1,24 @@
+// GoToSocial
+// Copyright (C) GoToSocial Authors admin@gotosocial.org
+// SPDX-License-Identifier: AGPL-3.0-or-later
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package util
+
+// Status is a helper type specifically
+// for updating the thread ID of a status.
+type Status struct {
+ ID string `bun:"type:CHAR(26)"`
+}