all repos — honk @ 51c88064130293ce6cbf051793f183c100b7191a

my fork of honk

database upgrade to fixup the subject lines
Ted Unangst tedu@tedunangst.com
Fri, 24 Feb 2023 13:09:45 -0500
commit

51c88064130293ce6cbf051793f183c100b7191a

parent

99bde417f4322a6eac405fba11bfd77f76c2201a

2 files changed, 33 insertions(+), 3 deletions(-)

jump to
M docs/changelog.txtdocs/changelog.txt

@@ -4,8 +4,6 @@ === next

+ Fix double htmlization of subject lines. -- Some existing posts will now have duplicated subjects. - + Remove the wonk support. Fun's over, back to work. + All inclusive danger zone spoiler alerts.
M upgradedb.goupgradedb.go

@@ -22,7 +22,7 @@ "strings"

"time" ) -var myVersion = 41 +var myVersion = 42 type dbexecer interface { Exec(query string, args ...interface{}) (sql.Result, error)

@@ -206,6 +206,38 @@ doordie(blobdb, "PRAGMA journal_mode=WAL")

doordie(db, "update config set value = 41 where key = 'dbversion'") fallthrough case 41: + tx, err := db.Begin() + if err != nil { + elog.Fatal(err) + } + rows, err := tx.Query("select honkid, noise from honks where format = 'markdown' and precis <> ''") + if err != nil { + elog.Fatal(err) + } + m := make(map[int64]string) + var dummy Honk + for rows.Next() { + err = rows.Scan(&dummy.ID, &dummy.Noise) + if err != nil { + elog.Fatal(err) + } + precipitate(&dummy) + m[dummy.ID] = dummy.Noise + } + rows.Close() + for id, noise := range m { + _, err = tx.Exec("update honks set noise = ? where honkid = ?", noise, id) + if err != nil { + elog.Fatal(err) + } + } + err = tx.Commit() + if err != nil { + elog.Fatal(err) + } + doordie(db, "update config set value = 42 where key = 'dbversion'") + fallthrough + case 42: default: elog.Fatalf("can't upgrade unknown version %d", dbversion)