diff --git a/appview/db/db.go b/appview/db/db.go --- a/appview/db/db.go +++ b/appview/db/db.go @@ -260,6 +260,7 @@ did text not null, -- data + avatar text, description text not null, include_bluesky integer not null default 0, location text, @@ -1078,7 +1079,7 @@ // transfer data, constructing pull_at from pulls table _, err = tx.Exec(` insert into pull_submissions_new (id, pull_at, round_number, patch, created) - select + select ps.id, 'at://' || p.owner_did || '/sh.tangled.repo.pull/' || p.rkey, ps.round_number, @@ -1169,6 +1170,13 @@ create index if not exists idx_stars_created on stars(created); create index if not exists idx_stars_subject_at_created on stars(subject_at, created); + `) + return err + }) + + orm.RunMigration(conn, logger, "add-avatar-to-profile", func(tx *sql.Tx) error { + _, err := tx.Exec(` + alter table profile add column avatar text; `) return err }) diff --git a/appview/db/profile.go b/appview/db/profile.go --- a/appview/db/profile.go +++ b/appview/db/profile.go @@ -158,13 +158,15 @@ _, err = tx.Exec( `insert or replace into profile ( did, + avatar, description, include_bluesky, location, pronouns ) - values (?, ?, ?, ?, ?)`, + values (?, ?, ?, ?, ?, ?)`, profile.Did, + profile.Avatar, profile.Description, includeBskyValue, profile.Location, @@ -347,15 +349,16 @@ func GetProfile(e Execer, did string) (*models.Profile, error) { var profile models.Profile var pronouns sql.Null[string] + var avatar sql.Null[string] profile.Did = did includeBluesky := 0 err := e.QueryRow( - `select description, include_bluesky, location, pronouns from profile where did = ?`, + `select avatar, description, include_bluesky, location, pronouns from profile where did = ?`, did, - ).Scan(&profile.Description, &includeBluesky, &profile.Location, &pronouns) + ).Scan(&avatar, &profile.Description, &includeBluesky, &profile.Location, &pronouns) if err == sql.ErrNoRows { profile := models.Profile{} profile.Did = did @@ -372,6 +375,10 @@ if pronouns.Valid { profile.Pronouns = pronouns.V + } + + if avatar.Valid { + profile.Avatar = avatar.V } rows, err := e.Query(`select link from profile_links where did = ?`, did) diff --git a/appview/models/profile.go b/appview/models/profile.go --- a/appview/models/profile.go +++ b/appview/models/profile.go @@ -13,6 +13,7 @@ Did string // data + Avatar string // CID of the avatar blob Description string IncludeBluesky bool Location string