2023-03-25 00:33:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
-- ========== Meeting tables
|
|
|
|
|
|
|
|
drop table "meeting_breakout";
|
|
|
|
drop table "meeting_recording";
|
|
|
|
drop table "meeting_welcome";
|
|
|
|
drop table "meeting_voice";
|
|
|
|
drop table "meeting_users";
|
|
|
|
drop table "meeting_metadata";
|
|
|
|
drop table "meeting_lockSettings";
|
|
|
|
drop table "meeting_group";
|
|
|
|
drop table "meeting";
|
|
|
|
|
|
|
|
create table "meeting" (
|
|
|
|
"meetingId" varchar(100) primary key,
|
|
|
|
"extId" varchar(100),
|
|
|
|
"name" varchar(100),
|
|
|
|
"isBreakout" boolean,
|
|
|
|
"disabledFeatures" varchar[],
|
|
|
|
"meetingCameraCap" integer,
|
|
|
|
"maxPinnedCameras" integer,
|
|
|
|
"notifyRecordingIsOn" boolean,
|
|
|
|
"presentationUploadExternalDescription" text,
|
|
|
|
"presentationUploadExternalUrl" varchar(500),
|
|
|
|
"learningDashboardAccessToken" varchar(100),
|
|
|
|
"html5InstanceId" varchar(100),
|
|
|
|
"createdTime" bigint,
|
|
|
|
"duration" integer
|
|
|
|
);
|
|
|
|
|
|
|
|
create table "meeting_breakout" (
|
|
|
|
"meetingId" varchar(100) primary key references "meeting"("meetingId") ON DELETE CASCADE,
|
|
|
|
"parentId" varchar(100),
|
|
|
|
"sequence" integer,
|
|
|
|
"freeJoin" boolean,
|
|
|
|
"breakoutRooms" varchar[],
|
|
|
|
"record" boolean,
|
|
|
|
"privateChatEnabled" boolean,
|
|
|
|
"captureNotes" boolean,
|
|
|
|
"captureSlides" boolean,
|
|
|
|
"captureNotesFilename" varchar(100),
|
|
|
|
"captureSlidesFilename" varchar(100)
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
create table "meeting_recording" (
|
|
|
|
"meetingId" varchar(100) primary key references "meeting"("meetingId") ON DELETE CASCADE,
|
|
|
|
"record" boolean,
|
|
|
|
"autoStartRecording" boolean,
|
|
|
|
"allowStartStopRecording" boolean,
|
|
|
|
"keepEvents" boolean
|
|
|
|
);
|
|
|
|
|
|
|
|
create table "meeting_welcome" (
|
|
|
|
"meetingId" varchar(100) primary key references "meeting"("meetingId") ON DELETE CASCADE,
|
|
|
|
"welcomeMsgTemplate" text,
|
|
|
|
"welcomeMsg" text,
|
|
|
|
"modOnlyMessage" text
|
|
|
|
);
|
|
|
|
|
|
|
|
create table "meeting_voice" (
|
|
|
|
"meetingId" varchar(100) primary key references "meeting"("meetingId") ON DELETE CASCADE,
|
|
|
|
"telVoice" varchar(100),
|
|
|
|
"voiceConf" varchar(100),
|
|
|
|
"dialNumber" varchar(100),
|
|
|
|
"muteOnStart" boolean
|
|
|
|
);
|
|
|
|
|
|
|
|
create table "meeting_users" (
|
|
|
|
"meetingId" varchar(100) primary key references "meeting"("meetingId") ON DELETE CASCADE,
|
|
|
|
"maxUsers" integer,
|
|
|
|
"maxUserConcurrentAccesses" integer,
|
|
|
|
"webcamsOnlyForModerator" boolean,
|
|
|
|
"userCameraCap" integer,
|
|
|
|
"guestPolicy" varchar(100),
|
|
|
|
"meetingLayout" varchar(100),
|
|
|
|
"allowModsToUnmuteUsers" boolean,
|
|
|
|
"allowModsToEjectCameras" boolean,
|
|
|
|
"authenticatedGuest" boolean
|
|
|
|
);
|
|
|
|
|
|
|
|
create table "meeting_metadata"(
|
|
|
|
"meetingId" varchar(100) references "meeting"("meetingId") ON DELETE CASCADE,
|
|
|
|
"name" varchar(255),
|
|
|
|
"value" varchar(255),
|
|
|
|
CONSTRAINT "meeting_metadata_pkey" PRIMARY KEY ("meetingId","name")
|
|
|
|
);
|
|
|
|
|
|
|
|
create table "meeting_lockSettings" (
|
|
|
|
"meetingId" varchar(100) primary key references "meeting"("meetingId") ON DELETE CASCADE,
|
|
|
|
"disableCam" boolean,
|
|
|
|
"disableMic" boolean,
|
|
|
|
"disablePrivateChat" boolean,
|
|
|
|
"disablePublicChat" boolean,
|
|
|
|
"disableNotes" boolean,
|
|
|
|
"hideUserList" boolean,
|
|
|
|
"lockOnJoin" boolean,
|
|
|
|
"lockOnJoinConfigurable" boolean,
|
|
|
|
"hideViewersCursor" boolean
|
|
|
|
);
|
|
|
|
|
|
|
|
create table "meeting_group" (
|
|
|
|
"meetingId" varchar(100) references "meeting"("meetingId") ON DELETE CASCADE,
|
|
|
|
"groupId" varchar(100),
|
|
|
|
"name" varchar(100),
|
|
|
|
"usersExtId" varchar[],
|
|
|
|
CONSTRAINT "meeting_group_pkey" PRIMARY KEY ("meetingId","groupId")
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
-- ========== User tables
|
|
|
|
|
2023-03-17 00:56:32 +08:00
|
|
|
DROP VIEW IF EXISTS "v_user_camera";
|
2023-03-25 00:33:08 +08:00
|
|
|
DROP VIEW IF EXISTS "v_user_voice";
|
2023-03-17 00:56:32 +08:00
|
|
|
DROP VIEW IF EXISTS "v_user_whiteboard";
|
|
|
|
DROP VIEW IF EXISTS "v_user_breakoutRoom";
|
|
|
|
DROP TABLE IF EXISTS "user_camera";
|
2023-03-25 00:33:08 +08:00
|
|
|
DROP TABLE IF EXISTS "user_voice";
|
2023-03-17 00:56:32 +08:00
|
|
|
DROP TABLE IF EXISTS "user_whiteboard";
|
|
|
|
DROP TABLE IF EXISTS "user_breakoutRoom";
|
|
|
|
DROP TABLE IF EXISTS "user";
|
2023-03-08 23:23:45 +08:00
|
|
|
|
|
|
|
CREATE TABLE public."user" (
|
2023-03-17 00:56:32 +08:00
|
|
|
"userId" varchar(50) NOT NULL PRIMARY KEY,
|
|
|
|
"extId" varchar(50) NULL,
|
2023-03-25 00:33:08 +08:00
|
|
|
"meetingId" varchar(100) NULL references "meeting"("meetingId") ON DELETE CASCADE,
|
2023-03-08 23:23:45 +08:00
|
|
|
"name" varchar(255) NULL,
|
2023-03-17 00:56:32 +08:00
|
|
|
"avatar" varchar(500) NULL,
|
|
|
|
"color" varchar(7) NULL,
|
2023-03-08 23:23:45 +08:00
|
|
|
"emoji" varchar,
|
|
|
|
"guest" bool NULL,
|
2023-03-17 00:56:32 +08:00
|
|
|
"guestStatus" varchar(50),
|
|
|
|
"mobile" bool NULL,
|
|
|
|
"clientType" varchar(50),
|
2023-03-08 23:23:45 +08:00
|
|
|
-- "excludeFromDashboard" bool NULL,
|
2023-03-17 00:56:32 +08:00
|
|
|
"role" varchar(20) NULL,
|
2023-03-08 23:23:45 +08:00
|
|
|
"authed" bool NULL,
|
|
|
|
"joined" bool NULL,
|
2023-03-17 00:56:32 +08:00
|
|
|
"leftFlag" bool NULL,
|
|
|
|
-- "ejected" bool null,
|
|
|
|
-- "ejectReason" varchar(255),
|
2023-03-08 23:23:45 +08:00
|
|
|
"banned" bool NULL,
|
|
|
|
"loggedOut" bool NULL,
|
2023-03-17 00:56:32 +08:00
|
|
|
"registeredOn" bigint NULL,
|
|
|
|
"presenter" bool NULL,
|
2023-03-08 23:23:45 +08:00
|
|
|
"pinned" bool NULL,
|
2023-03-17 00:56:32 +08:00
|
|
|
"locked" bool NULL
|
2023-03-08 23:23:45 +08:00
|
|
|
);
|
|
|
|
|
2023-03-17 00:56:32 +08:00
|
|
|
CREATE INDEX "user_meetingId" ON "user"("meetingId");
|
2023-03-08 23:23:45 +08:00
|
|
|
|
2023-03-25 00:33:08 +08:00
|
|
|
CREATE TABLE "user_voice" (
|
2023-03-17 00:56:32 +08:00
|
|
|
"voiceUserId" varchar(100) PRIMARY KEY,
|
|
|
|
"userId" varchar(50) NOT NULL REFERENCES "user"("userId") ON DELETE CASCADE,
|
|
|
|
"callerName" varchar(100),
|
|
|
|
"callerNum" varchar(100),
|
|
|
|
"callingWith" varchar(100),
|
|
|
|
"joined" boolean NULL,
|
|
|
|
"listenOnly" boolean NULL,
|
|
|
|
"muted" boolean NULL,
|
|
|
|
"spoke" boolean NULL,
|
|
|
|
"talking" boolean NULL,
|
|
|
|
"floor" boolean NULL,
|
2023-03-08 23:23:45 +08:00
|
|
|
"lastFloorTime" varchar(25),
|
2023-03-17 00:56:32 +08:00
|
|
|
"voiceConf" varchar(100),
|
2023-03-08 23:23:45 +08:00
|
|
|
"color" varchar(7),
|
2023-03-17 00:56:32 +08:00
|
|
|
"endTime" bigint NULL,
|
|
|
|
"startTime" bigint NULL
|
2023-03-08 23:23:45 +08:00
|
|
|
);
|
|
|
|
|
2023-03-25 00:33:08 +08:00
|
|
|
CREATE INDEX "user_voice_userId" ON "user_voice"("userId");
|
2023-03-17 00:56:32 +08:00
|
|
|
|
2023-03-25 00:33:08 +08:00
|
|
|
CREATE OR REPLACE VIEW "v_user_voice" AS
|
2023-03-17 00:56:32 +08:00
|
|
|
SELECT
|
|
|
|
u."meetingId",
|
2023-03-25 00:33:08 +08:00
|
|
|
"user_voice" .*
|
|
|
|
FROM "user_voice"
|
|
|
|
JOIN "user" u ON u."userId" = "user_voice"."userId";
|
2023-03-17 00:56:32 +08:00
|
|
|
|
|
|
|
CREATE TABLE "user_camera" (
|
|
|
|
"streamId" varchar(100) PRIMARY KEY,
|
|
|
|
"userId" varchar(50) NOT NULL REFERENCES "user"("userId") ON DELETE CASCADE
|
|
|
|
);
|
2023-03-08 23:23:45 +08:00
|
|
|
|
2023-03-17 00:56:32 +08:00
|
|
|
CREATE INDEX "user_camera_userId" ON "user_camera"("userId");
|
2023-03-08 23:23:45 +08:00
|
|
|
|
2023-03-17 00:56:32 +08:00
|
|
|
CREATE OR REPLACE VIEW "v_user_camera" AS
|
|
|
|
SELECT
|
|
|
|
u."meetingId",
|
|
|
|
"user_camera" .*
|
|
|
|
FROM "user_camera"
|
|
|
|
JOIN "user" u ON u."userId" = user_camera."userId";
|
2023-03-08 23:23:45 +08:00
|
|
|
|
2023-03-17 00:56:32 +08:00
|
|
|
CREATE TABLE "user_whiteboard" (
|
|
|
|
"whiteboardId" varchar(100),
|
|
|
|
"userId" varchar(50) REFERENCES "user"("userId") ON DELETE CASCADE,
|
|
|
|
"changedModeOn" bigint,
|
|
|
|
CONSTRAINT "user_whiteboard_pkey" PRIMARY KEY ("whiteboardId","userId")
|
2023-03-08 23:23:45 +08:00
|
|
|
);
|
|
|
|
|
2023-03-17 00:56:32 +08:00
|
|
|
CREATE INDEX "user_whiteboard_userId" ON "user_whiteboard"("userId");
|
|
|
|
|
|
|
|
CREATE OR REPLACE VIEW "v_user_whiteboard" AS
|
|
|
|
SELECT
|
|
|
|
u."meetingId",
|
|
|
|
"user_whiteboard" .*
|
|
|
|
FROM "user_whiteboard"
|
|
|
|
JOIN "user" u ON u."userId" = "user_whiteboard"."userId";
|
|
|
|
|
|
|
|
CREATE TABLE "user_breakoutRoom" (
|
|
|
|
"userId" varchar(50) PRIMARY KEY REFERENCES "user"("userId") ON DELETE CASCADE,
|
|
|
|
"breakoutRoomId" varchar(100),
|
|
|
|
"isDefaultName" boolean,
|
|
|
|
"sequence" int,
|
|
|
|
"shortName" varchar(100),
|
|
|
|
"online" boolean
|
|
|
|
);
|
2023-03-08 23:23:45 +08:00
|
|
|
|
2023-03-17 00:56:32 +08:00
|
|
|
CREATE OR REPLACE VIEW "v_user_breakoutRoom" AS
|
|
|
|
SELECT
|
|
|
|
u."meetingId",
|
|
|
|
"user_breakoutRoom" .*
|
|
|
|
FROM "user_breakoutRoom"
|
|
|
|
JOIN "user" u ON u."userId" = "user_breakoutRoom"."userId";
|
2023-03-29 20:55:41 +08:00
|
|
|
|
|
|
|
-- ===================== CHAT TABLES
|
|
|
|
|
|
|
|
DROP VIEW IF EXISTS "v_chat";
|
|
|
|
DROP VIEW IF EXISTS "v_chat_message_public";
|
|
|
|
DROP VIEW IF EXISTS "v_chat_message_private";
|
|
|
|
DROP TABLE IF EXISTS "chat_user";
|
|
|
|
DROP TABLE IF EXISTS "chat_message";
|
|
|
|
DROP TABLE IF EXISTS "chat";
|
|
|
|
|
|
|
|
CREATE TABLE "chat" (
|
|
|
|
"chatId" varchar(100),
|
|
|
|
"meetingId" varchar(100) REFERENCES "meeting"("meetingId") ON DELETE CASCADE,
|
|
|
|
"access" varchar(20),
|
|
|
|
"createdBy" varchar(25),
|
|
|
|
CONSTRAINT "chat_pkey" PRIMARY KEY ("chatId","meetingId")
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE INDEX "chat_meetingId" ON "chat"("meetingId");
|
|
|
|
|
|
|
|
CREATE TABLE "chat_user" (
|
|
|
|
"chatId" varchar(100),
|
|
|
|
"meetingId" varchar(100),
|
|
|
|
"userId" varchar(100),
|
|
|
|
"userName" varchar(255),
|
|
|
|
"userRole" varchar(20),
|
|
|
|
"lastSeenAt" bigint,
|
|
|
|
CONSTRAINT "chat_user_pkey" PRIMARY KEY ("chatId","meetingId","userId"),
|
|
|
|
CONSTRAINT chat_fk FOREIGN KEY ("chatId", "meetingId") REFERENCES "chat"("chatId", "meetingId") ON DELETE CASCADE
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE INDEX "chat_user_chatId" ON "chat_user"("chatId","meetingId");
|
|
|
|
|
|
|
|
CREATE TABLE "chat_message" (
|
|
|
|
"messageId" varchar(100) PRIMARY KEY,
|
|
|
|
"chatId" varchar(100),
|
|
|
|
"meetingId" varchar(100),
|
|
|
|
"correlationId" varchar(100),
|
|
|
|
"createdTime" bigint,
|
|
|
|
"chatEmphasizedText" boolean,
|
|
|
|
"message" TEXT,
|
|
|
|
"senderId" varchar(100),
|
|
|
|
"senderName" varchar(255),
|
|
|
|
"senderRole" varchar(20),
|
|
|
|
CONSTRAINT chat_fk FOREIGN KEY ("chatId", "meetingId") REFERENCES "chat"("chatId", "meetingId") ON DELETE CASCADE
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE INDEX "chat_message_chatId" ON "chat_message"("chatId","meetingId");
|
|
|
|
|
|
|
|
|
|
|
|
CREATE OR REPLACE VIEW "v_chat" AS
|
|
|
|
SELECT cu."userId",
|
|
|
|
chat."meetingId",
|
|
|
|
chat."chatId",
|
|
|
|
array_remove(array_agg(DISTINCT chat_with."userId"),NULL) "participantsId",
|
|
|
|
string_agg(DISTINCT chat_with."userName" ,', ') AS "participantsName",
|
|
|
|
count(DISTINCT cm."messageId") "totalMessages",
|
|
|
|
sum(CASE WHEN cm."createdTime" > cu."lastSeenAt" THEN 1 ELSE 0 end) "totalUnread"
|
|
|
|
FROM "user"
|
|
|
|
LEFT JOIN "chat_user" cu ON cu."meetingId" = "user"."meetingId" AND cu."userId" = "user"."userId"
|
|
|
|
JOIN "chat" ON cu."meetingId" = chat."meetingId" AND (cu."chatId" = chat."chatId" OR chat."chatId" = 'MAIN-PUBLIC-GROUP-CHAT')
|
|
|
|
LEFT JOIN "chat_user" chat_with ON chat_with."meetingId" = chat."meetingId" AND chat_with."chatId" = chat."chatId" AND chat_with."userId" != cu."userId"
|
|
|
|
LEFT JOIN chat_message cm ON cm."meetingId" = chat."meetingId" AND cm."chatId" = chat."chatId"
|
|
|
|
GROUP BY cu."userId", chat."meetingId", chat."chatId";
|
|
|
|
|
|
|
|
|
|
|
|
CREATE OR REPLACE VIEW "v_chat_message_public" AS
|
|
|
|
SELECT cm.*, to_timestamp("createdTime" / 1000) AS "createdTimeAsDate"
|
|
|
|
FROM chat_message cm
|
|
|
|
WHERE cm."chatId" = 'MAIN-PUBLIC-GROUP-CHAT';
|
|
|
|
|
|
|
|
CREATE OR REPLACE VIEW "v_chat_message_private" AS
|
|
|
|
SELECT cu."userId", cm.*, to_timestamp("createdTime" / 1000) AS "createdTimeAsDate"
|
|
|
|
FROM chat_message cm
|
|
|
|
JOIN chat_user cu ON cu."meetingId" = cm."meetingId" AND cu."chatId" = cm."chatId";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|