Use higher version numbers; fix sqlite query to increment better

This commit is contained in:
Kegan Dougal 2022-01-20 18:11:03 +00:00
parent 00ab416bad
commit a81c507d62
3 changed files with 3 additions and 4 deletions

View file

@ -20,6 +20,7 @@ import (
"github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/pressly/goose"
"github.com/sirupsen/logrus"
)
func LoadFromGoose() {
@ -31,6 +32,7 @@ func LoadRefactorKeyChanges(m *sqlutil.Migrations) {
}
func UpRefactorKeyChanges(tx *sql.Tx) error {
logrus.Infof("running delta!")
// start counting from the last max offset, else 0.
var maxOffset int64
_ = tx.QueryRow(`SELECT MAX(log_offset) FROM keyserver_key_changes`).Scan(&maxOffset)

View file

@ -37,11 +37,8 @@ CREATE TABLE IF NOT EXISTS keyserver_key_changes (
// Replace based on user ID. We don't care how many times the user's keys have changed, only that they
// have changed, hence we can just keep bumping the change ID for this user.
const upsertKeyChangeSQL = "" +
"INSERT INTO keyserver_key_changes (user_id)" +
"INSERT OR REPLACE INTO keyserver_key_changes (user_id)" +
" VALUES ($1)" +
" ON CONFLICT" +
// this only works because we rely on a single writer
" DO UPDATE SET change_id = change_id + 1" +
" RETURNING change_id"
const selectKeyChangesSQL = "" +