mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-29 09:43:10 -06:00
Use higher version numbers; fix sqlite query to increment better
This commit is contained in:
parent
00ab416bad
commit
a81c507d62
|
|
@ -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)
|
||||
|
|
@ -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 = "" +
|
||||
|
|
|
|||
Loading…
Reference in a new issue