Add upgrade path, rename table
This commit is contained in:
parent
3d76b7cb2b
commit
92ab45a330
|
@ -75,7 +75,7 @@ class RoomMemberStore(SQLBaseStore):
|
||||||
if event.membership == Membership.INVITE:
|
if event.membership == Membership.INVITE:
|
||||||
self._simple_insert_txn(
|
self._simple_insert_txn(
|
||||||
txn,
|
txn,
|
||||||
table="invites",
|
table="local_invites",
|
||||||
values={
|
values={
|
||||||
"event_id": event.event_id,
|
"event_id": event.event_id,
|
||||||
"invitee": event.state_key,
|
"invitee": event.state_key,
|
||||||
|
@ -86,7 +86,7 @@ class RoomMemberStore(SQLBaseStore):
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
sql = (
|
sql = (
|
||||||
"UPDATE invites SET stream_id = ?, replaced_by = ? WHERE"
|
"UPDATE local_invites SET stream_id = ?, replaced_by = ? WHERE"
|
||||||
" room_id = ? AND invitee = ? AND locally_rejected is NULL"
|
" room_id = ? AND invitee = ? AND locally_rejected is NULL"
|
||||||
" AND replaced_by is NULL"
|
" AND replaced_by is NULL"
|
||||||
)
|
)
|
||||||
|
@ -239,7 +239,7 @@ class RoomMemberStore(SQLBaseStore):
|
||||||
if do_invite:
|
if do_invite:
|
||||||
sql = (
|
sql = (
|
||||||
"SELECT i.room_id, inviter, i.event_id, e.stream_ordering"
|
"SELECT i.room_id, inviter, i.event_id, e.stream_ordering"
|
||||||
" FROM invites as i"
|
" FROM local_invites as i"
|
||||||
" INNER JOIN events as e USING (event_id)"
|
" INNER JOIN events as e USING (event_id)"
|
||||||
" WHERE invitee = ? AND locally_rejected is NULL"
|
" WHERE invitee = ? AND locally_rejected is NULL"
|
||||||
" AND replaced_by is NULL"
|
" AND replaced_by is NULL"
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE invites(
|
CREATE TABLE local_invites(
|
||||||
stream_id BIGINT NOT NULL,
|
stream_id BIGINT NOT NULL,
|
||||||
inviter TEXT NOT NULL,
|
inviter TEXT NOT NULL,
|
||||||
invitee TEXT NOT NULL,
|
invitee TEXT NOT NULL,
|
||||||
|
@ -24,5 +24,19 @@ CREATE TABLE invites(
|
||||||
replaced_by TEXT
|
replaced_by TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX invites_id ON invites(stream_id);
|
-- Insert all invites for local users into new `invites` table
|
||||||
CREATE INDEX invites_for_user_idx ON invites(invitee, locally_rejected, replaced_by, room_id);
|
INSERT INTO local_invites SELECT
|
||||||
|
stream_ordering as stream_id,
|
||||||
|
sender as inviter,
|
||||||
|
state_key as invitee,
|
||||||
|
event_id,
|
||||||
|
room_id,
|
||||||
|
NULL as locally_rejected,
|
||||||
|
NULL as replaced_by
|
||||||
|
FROM events
|
||||||
|
NATURAL JOIN current_state_events
|
||||||
|
NATURAL JOIN room_memberships
|
||||||
|
WHERE membership = 'invite' AND state_key IN (SELECT name FROM users);
|
||||||
|
|
||||||
|
CREATE INDEX local_invites_id ON local_invites(stream_id);
|
||||||
|
CREATE INDEX local_invites_for_user_idx ON local_invites(invitee, locally_rejected, replaced_by, room_id);
|
||||||
|
|
Loading…
Reference in New Issue