diff --git a/src/github.com/matrix-org/dendrite/syncapi/storage/account_data_table.go b/src/github.com/matrix-org/dendrite/syncapi/storage/account_data_table.go index 0c1d9b658..c51cfd19a 100644 --- a/src/github.com/matrix-org/dendrite/syncapi/storage/account_data_table.go +++ b/src/github.com/matrix-org/dendrite/syncapi/storage/account_data_table.go @@ -22,7 +22,7 @@ import ( const accountDataSchema = ` -- Stores the users account data -CREATE TABLE IF NOT EXISTS account_data ( +CREATE TABLE IF NOT EXISTS account_data_type ( -- The highest numeric ID from the output_room_events at the time of saving the data id BIGINT, -- ID of the user the data belongs to @@ -40,12 +40,12 @@ CREATE TABLE IF NOT EXISTS account_data ( ` const insertAccountDataSQL = "" + - "INSERT INTO account_data (id, user_id, room_id, type) VALUES ($1, $2, $3, $4)" + + "INSERT INTO account_data_type (id, user_id, room_id, type) VALUES ($1, $2, $3, $4)" + " ON CONFLICT ON CONSTRAINT account_data_unique" + " DO UPDATE SET id = EXCLUDED.id" const selectAccountDataInRangeSQL = "" + - "SELECT room_id, type FROM account_data" + + "SELECT room_id, type FROM account_data_type" + " WHERE user_id = $1 AND id > $2 AND id <= $3" + " ORDER BY id ASC"