Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#369 and #370: Add support for the clear chat room history event #408

Closed
16 changes: 14 additions & 2 deletions src/database/monitoring_db2.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@

INSERT INTO ofVersion (name, version) VALUES ('monitoring', 8);
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 9);

CREATE TABLE ofMucRoomStatus (
roomID INTEGER NOT NULL,
roomJID VARCHAR(512) NOT NULL,
roomDestroyed INTEGER NOT NULL,
CONSTRAINT ofMucRoomStatus_pk PRIMARY KEY (roomID)
);

CREATE TABLE ofConversation (
roomID INTEGER NOT NULL,
conversationID INTEGER NOT NULL,
room VARCHAR(512),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the room and isExernal columns be moved to the new table?

isExternal INTEGER NOT NULL,
Expand All @@ -10,22 +18,25 @@ CREATE TABLE ofConversation (
messageCount INTEGER NOT NULL,
CONSTRAINT ofConversation_pk PRIMARY KEY (conversationID)
);
CREATE INDEX ofConversation_room_idx ON ofConversation (roomID);
CREATE INDEX ofConversation_ext_idx ON ofConversation (isExternal);
CREATE INDEX ofConversation_start_idx ON ofConversation (startDate);
CREATE INDEX ofConversation_last_idx ON ofConversation (lastActivity);

CREATE TABLE ofConParticipant (
roomID INTEGER NOT NULL,
conversationID INTEGER NOT NULL,
joinedDate BIGINT NOT NULL,
leftDate BIGINT,
bareJID VARCHAR(255) NOT NULL,
jidResource VARCHAR(255) NOT NULL,
nickname VARCHAR(255)
);
CREATE INDEX entConPar_con_idx ON ofConParticipant (conversationID, bareJID, jidResource, joinedDate);
CREATE INDEX entConPar_con_idx ON ofConParticipant (roomID, conversationID, bareJID, jidResource, joinedDate);
CREATE INDEX entConPar_jid_idx ON ofConParticipant (bareJID);

CREATE TABLE ofMessageArchive (
roomID INTEGER NOT NULL,
messageID BIGINT NULL,
conversationID INTEGER NOT NULL,
fromJID VARCHAR(1024) NOT NULL,
Expand All @@ -37,6 +48,7 @@ CREATE TABLE ofMessageArchive (
body LONG VARCHAR NULL,
isPMforJID VARCHAR(1024) NULL
);
CREATE INDEX ofMessageArchive_room_idx ON ofMessageArchive (roomID);
CREATE INDEX ofMessageArchive_con_idx ON ofMessageArchive (conversationID);
CREATE INDEX ofMessageArchive_fromjid_idx ON ofMessageArchive (fromJID);
CREATE INDEX ofMessageArchive_tojid_idx ON ofMessageArchive (toJID);
Expand Down
16 changes: 14 additions & 2 deletions src/database/monitoring_hsqldb.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@

INSERT INTO ofVersion (name, version) VALUES ('monitoring', 8);
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 9);

CREATE TABLE ofMucRoomStatus (
roomID BIGINT NOT NULL,
roomJID VARCHAR(1024) NOT NULL,
roomDestroyed INT NOT NULL,
CONSTRAINT ofMucRoomStatus_pk PRIMARY KEY (roomID)
);

CREATE TABLE ofConversation (
roomID BIGINT NOT NULL,
conversationID BIGINT NOT NULL,
room VARCHAR(1024) NULL,
isExternal INT NOT NULL,
Expand All @@ -10,22 +18,25 @@ CREATE TABLE ofConversation (
messageCount INT NOT NULL,
CONSTRAINT ofConversation_pk PRIMARY KEY (conversationID)
);
CREATE INDEX ofConversation_room_idx ON ofConversation (roomID);
CREATE INDEX ofConversation_ext_idx ON ofConversation (isExternal);
CREATE INDEX ofConversation_start_idx ON ofConversation (startDate);
CREATE INDEX ofConversation_last_idx ON ofConversation (lastActivity);

CREATE TABLE ofConParticipant (
roomID BIGINT NOT NULL,
conversationID BIGINT NOT NULL,
joinedDate BIGINT NOT NULL,
leftDate BIGINT NULL,
bareJID VARCHAR(255) NOT NULL,
jidResource VARCHAR(255) NOT NULL,
nickname VARCHAR(255) NULL
);
CREATE INDEX ofConParticipant_conv_idx ON ofConParticipant (conversationID, bareJID, jidResource, joinedDate);
CREATE INDEX ofConParticipant_conv_idx ON ofConParticipant (roomID, conversationID, bareJID, jidResource, joinedDate);
CREATE INDEX ofConParticipant_jid_idx ON ofConParticipant (bareJID);

CREATE TABLE ofMessageArchive (
roomID BIGINT NOT NULL,
messageID BIGINT NULL,
conversationID BIGINT NOT NULL,
fromJID VARCHAR(1024) NOT NULL,
Expand All @@ -37,6 +48,7 @@ CREATE TABLE ofMessageArchive (
body LONGVARCHAR NULL,
isPMforJID VARCHAR(1024) NULL
);
CREATE INDEX ofMessageArchive_room_idx ON ofMessageArchive (roomID);
CREATE INDEX ofMessageArchive_con_idx ON ofMessageArchive (conversationID);
CREATE INDEX ofMessageArchive_fromjid_idx ON ofMessageArchive (fromJID);
CREATE INDEX ofMessageArchive_tojid_idx ON ofMessageArchive (toJID);
Expand Down
16 changes: 14 additions & 2 deletions src/database/monitoring_mysql.sql
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@

INSERT INTO ofVersion (name, version) VALUES ('monitoring', 8);
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 9);

CREATE TABLE ofMucRoomStatus (
roomID BIGINT NOT NULL,
roomJID VARCHAR(255) NOT NULL,
roomDestroyed TINYINT NOT NULL,
PRIMARY KEY (roomID)
);

CREATE TABLE ofConversation (
roomID BIGINT NOT NULL,
conversationID BIGINT NOT NULL,
room VARCHAR(255) NULL,
isExternal TINYINT NOT NULL,
startDate BIGINT NOT NULL,
lastActivity BIGINT NOT NULL,
messageCount INT NOT NULL,
PRIMARY KEY (conversationID),
INDEX ofConversation_room_idx (roomID),
INDEX ofConversation_ext_idx (isExternal),
INDEX ofConversation_start_idx (startDate),
INDEX ofConversation_last_idx (lastActivity)
);

CREATE TABLE ofConParticipant (
roomID BIGINT NOT NULL,
conversationID BIGINT NOT NULL,
joinedDate BIGINT NOT NULL,
leftDate BIGINT NULL,
bareJID VARCHAR(200) NOT NULL,
jidResource VARCHAR(100) NOT NULL,
nickname VARCHAR(255) NULL,
INDEX ofConParticipant_conv_idx (conversationID, bareJID, jidResource, joinedDate),
INDEX ofConParticipant_conv_idx (roomID, conversationID, bareJID, jidResource, joinedDate),
INDEX ofConParticipant_jid_idx (bareJID)
);

CREATE TABLE ofMessageArchive (
roomID BIGINT NOT NULL,
messageID BIGINT NULL,
conversationID BIGINT NOT NULL,
fromJID VARCHAR(255) NOT NULL,
Expand All @@ -36,6 +47,7 @@ CREATE TABLE ofMessageArchive (
stanza TEXT NULL,
body TEXT NULL,
isPMforJID VARCHAR(255) NULL,
INDEX ofMessageArchive_room_idx (roomID),
INDEX ofMessageArchive_con_idx (conversationID),
INDEX ofMessageArchive_fromjid_idx (fromJID),
INDEX ofMessageArchive_tojid_idx (toJID),
Expand Down
16 changes: 14 additions & 2 deletions src/database/monitoring_oracle.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@

INSERT INTO ofVersion (name, version) VALUES ('monitoring', 8);
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 9);

CREATE TABLE ofMucRoomStatus (
roomID INTEGER NOT NULL,
roomJID VARCHAR2(1024) NOT NULL,
roomDestroyed NUMBER(2) NOT NULL,
CONSTRAINT ofMucRoomStatus_pk PRIMARY KEY (roomID)
);

CREATE TABLE ofConversation (
roomID INTEGER NOT NULL,
conversationID INTEGER NOT NULL,
room VARCHAR2(1024) NULL,
isExternal NUMBER(2) NOT NULL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to miss the index that's created for other databases.

Expand All @@ -10,22 +18,25 @@ CREATE TABLE ofConversation (
messageCount INT NOT NULL,
CONSTRAINT ofConversation_pk PRIMARY KEY (conversationID)
);
CREATE INDEX ofConversation_room_idx ON ofConversation (roomID);
CREATE INDEX ofConversation_ext_idx ON ofConversation (isExternal);
CREATE INDEX ofConversation_start_idx ON ofConversation (startDate);
CREATE INDEX ofConversation_last_idx ON ofConversation (lastActivity);

CREATE TABLE ofConParticipant (
roomID INTEGER NOT NULL,
conversationID INTEGER NOT NULL,
joinedDate INTEGER NOT NULL,
leftDate INTEGER NULL,
bareJID VARCHAR2(255) NOT NULL,
jidResource VARCHAR2(255) NOT NULL,
nickname VARCHAR2(255) NULL
);
CREATE INDEX ofConParticipant_conv_idx ON ofConParticipant (conversationID, bareJID, jidResource, joinedDate);
CREATE INDEX ofConParticipant_conv_idx ON ofConParticipant (roomID, conversationID, bareJID, jidResource, joinedDate);
CREATE INDEX ofConParticipant_jid_idx ON ofConParticipant (bareJID);

CREATE TABLE ofMessageArchive (
roomID INTEGER NOT NULL,
messageID INTEGER NULL,
conversationID INTEGER NOT NULL,
fromJID VARCHAR2(1024) NOT NULL,
Expand All @@ -37,6 +48,7 @@ CREATE TABLE ofMessageArchive (
body CLOB NULL,
isPMforJID VARCHAR2(1024) NULL
);
CREATE INDEX ofMessageArchive_room_idx ON ofMessageArchive (roomID);
CREATE INDEX ofMessageArchive_con_idx ON ofMessageArchive (conversationID);
CREATE INDEX ofMessageArchive_fromjid_idx ON ofMessageArchive (fromJID);
CREATE INDEX ofMessageArchive_tojid_idx ON ofMessageArchive (toJID);
Expand Down
16 changes: 14 additions & 2 deletions src/database/monitoring_postgresql.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@

INSERT INTO ofVersion (name, version) VALUES ('monitoring', 8);
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 9);

CREATE TABLE ofMucRoomStatus (
roomID INTEGER NOT NULL,
roomJID VARCHAR(1024) NOT NULL,
roomDestroyed SMALLINT NOT NULL,
CONSTRAINT ofMucRoomStatus_pk PRIMARY KEY (roomID)
);

CREATE TABLE ofConversation (
roomID INTEGER NOT NULL,
conversationID INTEGER NOT NULL,
room VARCHAR(1024) NULL,
isExternal SMALLINT NOT NULL,
Expand All @@ -10,22 +18,25 @@ CREATE TABLE ofConversation (
messageCount INTEGER NOT NULL,
CONSTRAINT ofConversation_pk PRIMARY KEY (conversationID)
);
CREATE INDEX ofConversation_room_idx ON ofConversation (roomID);
CREATE INDEX ofConversation_ext_idx ON ofConversation (isExternal);
CREATE INDEX ofConversation_start_idx ON ofConversation (startDate);
CREATE INDEX ofConversation_last_idx ON ofConversation (lastActivity);

CREATE TABLE ofConParticipant (
roomID INTEGER NOT NULL,
conversationID INTEGER NOT NULL,
joinedDate BIGINT NOT NULL,
leftDate BIGINT NULL,
bareJID VARCHAR(255) NOT NULL,
jidResource VARCHAR(255) NOT NULL,
nickname VARCHAR(255) NULL
);
CREATE INDEX ofConParticipant_conv_idx ON ofConParticipant (conversationID, bareJID, jidResource, joinedDate);
CREATE INDEX ofConParticipant_conv_idx ON ofConParticipant (roomID, conversationID, bareJID, jidResource, joinedDate);
CREATE INDEX ofConParticipant_jid_idx ON ofConParticipant (bareJID);

CREATE TABLE ofMessageArchive (
roomID INTEGER NOT NULL,
messageID BIGINT NULL,
conversationID INTEGER NOT NULL,
fromJID VARCHAR(1024) NOT NULL,
Expand All @@ -37,6 +48,7 @@ CREATE TABLE ofMessageArchive (
body TEXT NULL,
isPMforJID VARCHAR(1024) NULL
);
CREATE INDEX ofMessageArchive_room_idx ON ofMessageArchive (roomID);
CREATE INDEX ofMessageArchive_con_idx ON ofMessageArchive (conversationID);
CREATE INDEX ofMessageArchive_fromjid_idx ON ofMessageArchive (fromJID);
CREATE INDEX ofMessageArchive_tojid_idx ON ofMessageArchive (toJID);
Expand Down
16 changes: 14 additions & 2 deletions src/database/monitoring_sqlserver.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@

INSERT INTO ofVersion (name, version) VALUES ('monitoring', 8);
INSERT INTO ofVersion (name, version) VALUES ('monitoring', 9);

CREATE TABLE ofMucRoomStatus (
roomID BIGINT NOT NULL,
roomJID NVARCHAR(1024) NOT NULL,
roomDestroyed TINYINT NOT NULL,
CONSTRAINT ofMucRoomStatus_pk PRIMARY KEY (roomID)
);

CREATE TABLE ofConversation (
roomID BIGINT NOT NULL,
conversationID BIGINT NOT NULL,
room NVARCHAR(1024) NULL,
isExternal TINYINT NOT NULL,
Expand All @@ -10,22 +18,25 @@ CREATE TABLE ofConversation (
messageCount INT NOT NULL,
CONSTRAINT ofConversation_pk PRIMARY KEY (conversationID)
);
CREATE INDEX ofConversation_room_idx ON ofConversation (roomID);
CREATE INDEX ofConversation_ext_idx ON ofConversation (isExternal);
CREATE INDEX ofConversation_start_idx ON ofConversation (startDate);
CREATE INDEX ofConversation_last_idx ON ofConversation (lastActivity);

CREATE TABLE ofConParticipant (
roomID BIGINT NOT NULL,
conversationID BIGINT NOT NULL,
joinedDate BIGINT NOT NULL,
leftDate BIGINT NULL,
bareJID NVARCHAR(255) NOT NULL,
jidResource NVARCHAR(255) NOT NULL,
nickname NVARCHAR(255) NULL
);
CREATE INDEX ofConParticipant_conv_idx ON ofConParticipant (conversationID, bareJID, jidResource, joinedDate);
CREATE INDEX ofConParticipant_conv_idx ON ofConParticipant (roomID, conversationID, bareJID, jidResource, joinedDate);
CREATE INDEX ofConParticipant_jid_idx ON ofConParticipant (bareJID);

CREATE TABLE ofMessageArchive (
roomID BIGINT NOT NULL,
messageID BIGINT NULL,
conversationID BIGINT NOT NULL,
fromJID NVARCHAR(1024) NOT NULL,
Expand All @@ -37,6 +48,7 @@ CREATE TABLE ofMessageArchive (
body NVARCHAR(MAX) NULL,
isPMforJID NVARCHAR(1024) NULL
);
CREATE INDEX ofMessageArchive_room_idx ON ofMessageArchive (roomID);
CREATE INDEX ofMessageArchive_con_idx ON ofMessageArchive (conversationID);
CREATE INDEX ofMessageArchive_fromjid_idx ON ofMessageArchive (fromJID);
CREATE INDEX ofMessageArchive_tojid_idx ON ofMessageArchive (toJID);
Expand Down
19 changes: 19 additions & 0 deletions src/database/upgrade/9/monitoring_db2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CREATE TABLE ofMucRoomStatus (
roomID INTEGER NOT NULL,
roomJID VARCHAR(512) NOT NULL,
roomDestroyed INTEGER NOT NULL,
CONSTRAINT ofMucRoomStatus_pk PRIMARY KEY (roomID)
);

ALTER TABLE ofConversation ADD COLUMN roomID INTEGER DEFAULT -1 NOT NULL;
CREATE INDEX ofConversation_room_idx ON ofConversation (roomID);

ALTER TABLE ofConParticipant ADD COLUMN roomID INTEGER DEFAULT -1 NOT NULL;
DROP INDEX entConPar_con_idx;
CREATE INDEX entConPar_con_idx ON ofConParticipant (roomID, conversationID, bareJID, jidResource, joinedDate);

ALTER TABLE ofMessageArchive ADD COLUMN roomID INTEGER DEFAULT -1 NOT NULL;
CREATE INDEX ofMessageArchive_room_idx ON ofMessageArchive (roomID);

-- Update database version
UPDATE ofVersion SET version = 9 WHERE name = 'monitoring';
19 changes: 19 additions & 0 deletions src/database/upgrade/9/monitoring_hsqldb.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CREATE TABLE ofMucRoomStatus (
roomID BIGINT NOT NULL,
roomJID VARCHAR(1024) NOT NULL,
roomDestroyed INT NOT NULL,
CONSTRAINT ofMucRoomStatus_pk PRIMARY KEY (roomID)
);

ALTER TABLE ofConversation ADD COLUMN roomID BIGINT DEFAULT -1 NOT NULL;
CREATE INDEX ofConversation_room_idx ON ofConversation (roomID);

ALTER TABLE ofConParticipant ADD COLUMN roomID BIGINT DEFAULT -1 NOT NULL;
DROP INDEX ofConParticipant_conv_idx;
CREATE INDEX ofConParticipant_conv_idx ON ofConParticipant (roomID, conversationID, bareJID, jidResource, joinedDate);

ALTER TABLE ofMessageArchive ADD COLUMN roomID BIGINT DEFAULT -1 NOT NULL;
CREATE INDEX ofMessageArchive_room_idx ON ofMessageArchive (roomID);

-- Update database version
UPDATE ofVersion SET version = 9 WHERE name = 'monitoring';
19 changes: 19 additions & 0 deletions src/database/upgrade/9/monitoring_mysql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CREATE TABLE ofMucRoomStatus (
roomID BIGINT NOT NULL,
roomJID VARCHAR(255) NOT NULL,
roomDestroyed TINYINT NOT NULL,
PRIMARY KEY (roomID)
);

ALTER TABLE ofConversation ADD COLUMN roomID BIGINT NOT NULL DEFAULT -1;
CREATE INDEX ofConversation_room_idx ON ofConversation (roomID);

ALTER TABLE ofConParticipant ADD COLUMN roomID BIGINT NOT NULL DEFAULT -1;
DROP INDEX ofConParticipant_conv_idx ON ofConParticipant;
CREATE INDEX ofConParticipant_conv_idx ON ofConParticipant (roomID, conversationID, bareJID, jidResource, joinedDate);

ALTER TABLE ofMessageArchive ADD COLUMN roomID BIGINT NOT NULL DEFAULT -1;
CREATE INDEX ofMessageArchive_room_idx ON ofMessageArchive (roomID);

-- Update database version
UPDATE ofVersion SET version = 9 WHERE name = 'monitoring';
19 changes: 19 additions & 0 deletions src/database/upgrade/9/monitoring_oracle.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CREATE TABLE ofMucRoomStatus (
roomID INTEGER NOT NULL,
roomJID VARCHAR2(1024) NOT NULL,
roomDestroyed NUMBER(2) NOT NULL,
CONSTRAINT ofMucRoomStatus_pk PRIMARY KEY (roomID)
);

ALTER TABLE ofConversation ADD (roomID INTEGER DEFAULT -1 NOT NULL);
CREATE INDEX ofConversation_room_idx ON ofConversation (roomID);

ALTER TABLE ofConParticipant ADD (roomID INTEGER DEFAULT -1 NOT NULL);
DROP INDEX ofConParticipant_conv_idx;
CREATE INDEX ofConParticipant_conv_idx ON ofConParticipant (roomID, conversationID, bareJID, jidResource, joinedDate);

ALTER TABLE ofMessageArchive ADD (roomID INTEGER DEFAULT -1 NOT NULL);
CREATE INDEX ofMessageArchive_room_idx ON ofMessageArchive (roomID);

-- Update database version
UPDATE ofVersion SET version = 9 WHERE name = 'monitoring';
Loading
Loading