[chore] Migrate accounts to new table, relax uniqueness constraint of actor url and collections

This commit is contained in:
tobi 2025-04-02 12:40:35 +02:00
commit fe352c69b5
37 changed files with 1270 additions and 566 deletions

15
internal/cache/db.go vendored
View file

@ -304,15 +304,18 @@ func (c *Caches) initAccount() {
c.DB.Account.Init(structr.CacheConfig[*gtsmodel.Account]{
Indices: []structr.IndexConfig{
// Unique fields.
{Fields: "ID"},
{Fields: "URI"},
{Fields: "URL"},
{Fields: "Username,Domain", AllowZero: true},
{Fields: "PublicKeyURI"},
{Fields: "InboxURI"},
{Fields: "OutboxURI"},
{Fields: "FollowersURI"},
{Fields: "FollowingURI"},
{Fields: "Username,Domain", AllowZero: true},
// Potentially non-unique fields.
{Fields: "URL", Multiple: true},
{Fields: "InboxURI", Multiple: true},
{Fields: "OutboxURI", Multiple: true},
{Fields: "FollowersURI", Multiple: true},
{Fields: "FollowingURI", Multiple: true},
},
MaxSize: cap,
IgnoreErr: ignoreErrors,

View file

@ -240,13 +240,12 @@ func sizeofAccount() uintptr {
DisplayName: exampleUsername,
Note: exampleText,
NoteRaw: exampleText,
Memorial: func() *bool { ok := false; return &ok }(),
MemorializedAt: exampleTime,
CreatedAt: exampleTime,
UpdatedAt: exampleTime,
FetchedAt: exampleTime,
Bot: func() *bool { ok := true; return &ok }(),
Locked: func() *bool { ok := true; return &ok }(),
Discoverable: func() *bool { ok := false; return &ok }(),
Locked: util.Ptr(true),
Discoverable: util.Ptr(false),
URI: exampleURI,
URL: exampleURI,
InboxURI: exampleURI,
@ -254,7 +253,7 @@ func sizeofAccount() uintptr {
FollowersURI: exampleURI,
FollowingURI: exampleURI,
FeaturedCollectionURI: exampleURI,
ActorType: ap.ActorPerson,
ActorType: gtsmodel.AccountActorTypePerson,
PrivateKey: &rsa.PrivateKey{},
PublicKey: &rsa.PublicKey{},
PublicKeyURI: exampleURI,