2023-04-06 00:56:22 +08:00
|
|
|
DROP VIEW IF EXISTS "v_pres_annotation_curr";
|
|
|
|
DROP VIEW IF EXISTS "v_pres_annotation_history_curr";
|
|
|
|
DROP VIEW IF EXISTS "v_pres_page_cursor";
|
|
|
|
DROP VIEW IF EXISTS "v_pres_page_writers";
|
|
|
|
DROP TABLE IF EXISTS "pres_annotation_history";
|
|
|
|
DROP TABLE IF EXISTS "pres_annotation";
|
|
|
|
DROP TABLE IF EXISTS "pres_page_cursor";
|
|
|
|
DROP TABLE IF EXISTS "pres_page_writers";
|
|
|
|
DROP TABLE IF EXISTS "pres_page";
|
|
|
|
DROP TABLE IF EXISTS "pres_presentation";
|
2023-03-25 00:33:08 +08:00
|
|
|
|
2023-04-01 04:46:17 +08:00
|
|
|
DROP VIEW IF EXISTS "v_chat";
|
|
|
|
DROP VIEW IF EXISTS "v_chat_message_public";
|
|
|
|
DROP VIEW IF EXISTS "v_chat_message_private";
|
|
|
|
DROP VIEW IF EXISTS "v_chat_participant";
|
2023-04-12 22:30:12 +08:00
|
|
|
DROP VIEW IF EXISTS "v_user_typing_public";
|
2023-04-01 04:46:17 +08:00
|
|
|
DROP TABLE IF EXISTS "chat_user";
|
|
|
|
DROP TABLE IF EXISTS "chat_message";
|
|
|
|
DROP TABLE IF EXISTS "chat";
|
|
|
|
|
|
|
|
DROP VIEW IF EXISTS "v_user_camera";
|
|
|
|
DROP VIEW IF EXISTS "v_user_voice";
|
|
|
|
--DROP VIEW IF EXISTS "v_user_whiteboard";
|
|
|
|
DROP VIEW IF EXISTS "v_user_breakoutRoom";
|
2023-04-12 22:07:54 +08:00
|
|
|
DROP VIEW IF EXISTS "v_user";
|
2023-04-17 23:04:38 +08:00
|
|
|
DROP VIEW IF EXISTS "v_user_current";
|
2023-04-12 22:07:54 +08:00
|
|
|
DROP VIEW IF EXISTS "v_user_ref";
|
2023-04-01 04:46:17 +08:00
|
|
|
DROP TABLE IF EXISTS "user_camera";
|
|
|
|
DROP TABLE IF EXISTS "user_voice";
|
|
|
|
--DROP TABLE IF EXISTS "user_whiteboard";
|
|
|
|
DROP TABLE IF EXISTS "user_breakoutRoom";
|
2023-04-12 22:30:12 +08:00
|
|
|
DROP TABLE IF EXISTS "user_connectionStatus";
|
2023-04-01 04:46:17 +08:00
|
|
|
DROP TABLE IF EXISTS "user";
|
|
|
|
|
2023-04-11 02:57:35 +08:00
|
|
|
drop view if exists "v_meeting_lockSettings";
|
2023-04-12 22:30:12 +08:00
|
|
|
drop view if exists "v_meeting_usersPolicies";
|
2023-04-01 04:46:17 +08:00
|
|
|
drop table if exists "meeting_breakout";
|
|
|
|
drop table if exists "meeting_recording";
|
|
|
|
drop table if exists "meeting_welcome";
|
|
|
|
drop table if exists "meeting_voice";
|
|
|
|
drop table if exists "meeting_users";
|
|
|
|
drop table if exists "meeting_metadata";
|
|
|
|
drop table if exists "meeting_lockSettings";
|
2023-04-12 22:30:12 +08:00
|
|
|
drop table if exists "meeting_usersPolicies";
|
2023-04-01 04:46:17 +08:00
|
|
|
drop table if exists "meeting_group";
|
|
|
|
drop table if exists "meeting";
|
2023-03-25 00:33:08 +08:00
|
|
|
|
|
|
|
-- ========== Meeting tables
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
);
|
2023-04-01 04:46:17 +08:00
|
|
|
create index "idx_meeting_breakout_meetingId" on "meeting_breakout"("meetingId");
|
2023-03-25 00:33:08 +08:00
|
|
|
|
|
|
|
create table "meeting_recording" (
|
|
|
|
"meetingId" varchar(100) primary key references "meeting"("meetingId") ON DELETE CASCADE,
|
2023-04-12 22:30:12 +08:00
|
|
|
"record" boolean,
|
|
|
|
"autoStartRecording" boolean,
|
|
|
|
"allowStartStopRecording" boolean,
|
2023-03-25 00:33:08 +08:00
|
|
|
"keepEvents" boolean
|
|
|
|
);
|
2023-04-01 04:46:17 +08:00
|
|
|
create index "idx_meeting_recording_meetingId" on "meeting_recording"("meetingId");
|
2023-03-25 00:33:08 +08:00
|
|
|
|
|
|
|
create table "meeting_welcome" (
|
|
|
|
"meetingId" varchar(100) primary key references "meeting"("meetingId") ON DELETE CASCADE,
|
2023-04-12 22:30:12 +08:00
|
|
|
"welcomeMsgTemplate" text,
|
|
|
|
"welcomeMsg" text,
|
2023-03-25 00:33:08 +08:00
|
|
|
"modOnlyMessage" text
|
|
|
|
);
|
2023-04-01 04:46:17 +08:00
|
|
|
create index "idx_meeting_welcome_meetingId" on "meeting_welcome"("meetingId");
|
2023-03-25 00:33:08 +08:00
|
|
|
|
|
|
|
create table "meeting_voice" (
|
|
|
|
"meetingId" varchar(100) primary key references "meeting"("meetingId") ON DELETE CASCADE,
|
2023-04-12 22:30:12 +08:00
|
|
|
"telVoice" varchar(100),
|
|
|
|
"voiceConf" varchar(100),
|
|
|
|
"dialNumber" varchar(100),
|
2023-03-25 00:33:08 +08:00
|
|
|
"muteOnStart" boolean
|
|
|
|
);
|
2023-04-01 04:46:17 +08:00
|
|
|
create index "idx_meeting_voice_meetingId" on "meeting_voice"("meetingId");
|
2023-03-25 00:33:08 +08:00
|
|
|
|
2023-04-12 22:07:54 +08:00
|
|
|
create table "meeting_usersPolicies" (
|
2023-03-25 00:33:08 +08:00
|
|
|
"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
|
|
|
|
);
|
2023-04-12 22:07:54 +08:00
|
|
|
create index "idx_meeting_usersPolicies_meetingId" on "meeting_usersPolicies"("meetingId");
|
|
|
|
|
|
|
|
CREATE OR REPLACE VIEW "v_meeting_usersPolicies" AS SELECT * FROM "meeting_usersPolicies";
|
2023-03-25 00:33:08 +08:00
|
|
|
|
|
|
|
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")
|
|
|
|
);
|
2023-04-01 04:46:17 +08:00
|
|
|
create index "idx_meeting_metadata_meetingId" on "meeting_metadata"("meetingId");
|
2023-03-25 00:33:08 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
);
|
2023-04-01 04:46:17 +08:00
|
|
|
create index "idx_meeting_lockSettings_meetingId" on "meeting_lockSettings"("meetingId");
|
2023-03-25 00:33:08 +08:00
|
|
|
|
2023-04-11 02:57:35 +08:00
|
|
|
CREATE OR REPLACE VIEW "v_meeting_lockSettings" AS
|
|
|
|
SELECT
|
|
|
|
mls."meetingId",
|
|
|
|
mls."disableCam",
|
|
|
|
mls."disableMic",
|
|
|
|
mls."disablePrivateChat",
|
|
|
|
mls."disablePublicChat",
|
|
|
|
mls."disableNotes",
|
|
|
|
mls."hideUserList",
|
|
|
|
mls."hideViewersCursor",
|
2023-04-12 22:30:12 +08:00
|
|
|
mup."webcamsOnlyForModerator",
|
2023-04-11 02:57:35 +08:00
|
|
|
CASE WHEN
|
|
|
|
mls."disableCam" IS TRUE THEN TRUE
|
|
|
|
WHEN mls."disableMic" IS TRUE THEN TRUE
|
|
|
|
WHEN mls."disablePrivateChat" IS TRUE THEN TRUE
|
|
|
|
WHEN mls."disablePublicChat" IS TRUE THEN TRUE
|
|
|
|
WHEN mls."disableNotes" IS TRUE THEN TRUE
|
|
|
|
WHEN mls."hideUserList" IS TRUE THEN TRUE
|
|
|
|
WHEN mls."hideViewersCursor" IS TRUE THEN TRUE
|
2023-04-12 22:30:12 +08:00
|
|
|
WHEN mup."webcamsOnlyForModerator" IS TRUE THEN TRUE
|
2023-04-11 02:57:35 +08:00
|
|
|
ELSE FALSE
|
|
|
|
END "hasActiveLockSetting"
|
|
|
|
FROM meeting m
|
|
|
|
JOIN "meeting_lockSettings" mls ON mls."meetingId" = m."meetingId"
|
2023-04-12 22:30:12 +08:00
|
|
|
JOIN "meeting_usersPolicies" mup ON mup."meetingId" = m."meetingId";
|
2023-04-11 02:57:35 +08:00
|
|
|
|
2023-03-25 00:33:08 +08:00
|
|
|
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")
|
|
|
|
);
|
2023-04-01 04:46:17 +08:00
|
|
|
create index "idx_meeting_group_meetingId" on "meeting_group"("meetingId");
|
2023-03-25 00:33:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
-- ========== User tables
|
|
|
|
|
2023-03-08 23:23:45 +08:00
|
|
|
|
2023-04-06 00:56:22 +08:00
|
|
|
CREATE TABLE "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-04-01 04:46:17 +08:00
|
|
|
CREATE INDEX "idx_user_meetingId" ON "user"("meetingId");
|
2023-03-08 23:23:45 +08:00
|
|
|
|
2023-04-06 00:56:22 +08:00
|
|
|
--Virtual columns isModerator and isOnline
|
2023-04-12 22:07:54 +08:00
|
|
|
--ALTER TABLE "user" ADD COLUMN "isModerator" boolean GENERATED ALWAYS AS (CASE WHEN "role" = 'MODERATOR' THEN true ELSE false END) STORED;
|
|
|
|
--ALTER TABLE "user" ADD COLUMN "isOnline" boolean GENERATED ALWAYS AS (CASE WHEN "joined" IS true AND "loggedOut" IS false THEN true ELSE false END) STORED;
|
|
|
|
|
|
|
|
CREATE OR REPLACE VIEW "v_user"
|
|
|
|
AS SELECT "user"."userId",
|
|
|
|
"user"."extId",
|
|
|
|
"user"."meetingId",
|
|
|
|
"user"."name",
|
|
|
|
"user"."avatar",
|
|
|
|
"user"."color",
|
|
|
|
"user"."emoji",
|
|
|
|
"user"."guest",
|
|
|
|
"user"."guestStatus",
|
|
|
|
"user"."mobile",
|
|
|
|
"user"."clientType",
|
|
|
|
"user"."role",
|
|
|
|
"user"."authed",
|
|
|
|
"user"."joined",
|
|
|
|
"user"."leftFlag",
|
|
|
|
"user"."banned",
|
|
|
|
"user"."loggedOut",
|
|
|
|
"user"."registeredOn",
|
|
|
|
"user"."presenter",
|
|
|
|
"user"."pinned",
|
|
|
|
"user"."locked",
|
|
|
|
CASE WHEN "user"."role" = 'MODERATOR' THEN true ELSE false END "isModerator",
|
|
|
|
CASE WHEN "user"."joined" IS true AND "user"."loggedOut" IS false THEN true ELSE false END "isOnline"
|
|
|
|
FROM "user"
|
|
|
|
WHERE "user"."loggedOut" IS FALSE
|
|
|
|
AND "user".joined IS TRUE;
|
2023-04-13 19:40:14 +08:00
|
|
|
CREATE INDEX "idx_v_user_meetingId" ON "user"("meetingId") where "user"."loggedOut" IS FALSE and "user"."joined" IS TRUE;
|
|
|
|
CREATE INDEX "idx_v_user_meetingId_orderByColumns" ON "user"("meetingId","role","name","userId") where "user"."loggedOut" IS FALSE and "user"."joined" IS TRUE;
|
2023-04-12 22:07:54 +08:00
|
|
|
|
2023-04-17 23:04:38 +08:00
|
|
|
CREATE OR REPLACE VIEW "v_user_current"
|
|
|
|
AS SELECT "user"."userId",
|
|
|
|
"user"."extId",
|
|
|
|
"user"."meetingId",
|
|
|
|
"user"."name",
|
|
|
|
"user"."avatar",
|
|
|
|
"user"."color",
|
|
|
|
"user"."emoji",
|
|
|
|
"user"."guest",
|
|
|
|
"user"."guestStatus",
|
|
|
|
"user"."mobile",
|
|
|
|
"user"."clientType",
|
|
|
|
"user"."role",
|
|
|
|
"user"."authed",
|
|
|
|
"user"."joined",
|
|
|
|
"user"."leftFlag",
|
|
|
|
"user"."banned",
|
|
|
|
"user"."loggedOut",
|
|
|
|
"user"."registeredOn",
|
|
|
|
"user"."presenter",
|
|
|
|
"user"."pinned",
|
|
|
|
"user"."locked",
|
|
|
|
CASE WHEN "user"."role" = 'MODERATOR' THEN true ELSE false END "isModerator"
|
|
|
|
FROM "user";
|
|
|
|
|
2023-04-12 22:07:54 +08:00
|
|
|
--v_user_ref will be used only as foreign key (not possible to fetch this table directly through graphql)
|
|
|
|
--it is necessary because v_user has some conditions like "lockSettings-hideUserList"
|
|
|
|
--but viewers still needs to query this users as foreign key of chat, cameras, etc
|
|
|
|
CREATE OR REPLACE VIEW "v_user_ref"
|
|
|
|
AS SELECT "user"."userId",
|
|
|
|
"user"."extId",
|
|
|
|
"user"."meetingId",
|
|
|
|
"user"."name",
|
|
|
|
"user"."avatar",
|
|
|
|
"user"."color",
|
|
|
|
"user"."emoji",
|
|
|
|
"user"."guest",
|
|
|
|
"user"."guestStatus",
|
|
|
|
"user"."mobile",
|
|
|
|
"user"."clientType",
|
|
|
|
"user"."role",
|
|
|
|
"user"."authed",
|
|
|
|
"user"."joined",
|
|
|
|
"user"."leftFlag",
|
|
|
|
"user"."banned",
|
|
|
|
"user"."loggedOut",
|
|
|
|
"user"."registeredOn",
|
|
|
|
"user"."presenter",
|
|
|
|
"user"."pinned",
|
|
|
|
"user"."locked",
|
|
|
|
CASE WHEN "user"."role" = 'MODERATOR' THEN true ELSE false END "isModerator",
|
|
|
|
CASE WHEN "user"."joined" IS true AND "user"."loggedOut" IS false THEN true ELSE false END "isOnline"
|
|
|
|
FROM "user";
|
2023-04-06 00:56:22 +08:00
|
|
|
|
2023-03-25 00:33:08 +08:00
|
|
|
CREATE TABLE "user_voice" (
|
2023-04-04 20:02:41 +08:00
|
|
|
"userId" varchar(50) PRIMARY KEY NOT NULL REFERENCES "user"("userId") ON DELETE CASCADE,
|
|
|
|
"voiceUserId" varchar(100),
|
2023-03-17 00:56:32 +08:00
|
|
|
"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-04-04 20:02:41 +08:00
|
|
|
--CREATE INDEX "idx_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-04-04 04:23:30 +08:00
|
|
|
"user_voice" .*,
|
|
|
|
greatest(coalesce(user_voice."startTime", 0), coalesce(user_voice."endTime", 0)) AS "lastSpeakChangedAt"
|
2023-03-25 00:33:08 +08:00
|
|
|
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-04-01 04:46:17 +08:00
|
|
|
CREATE INDEX "idx_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_breakoutRoom" (
|
|
|
|
"userId" varchar(50) PRIMARY KEY REFERENCES "user"("userId") ON DELETE CASCADE,
|
|
|
|
"breakoutRoomId" varchar(100),
|
|
|
|
"isDefaultName" boolean,
|
|
|
|
"sequence" int,
|
|
|
|
"shortName" varchar(100),
|
2023-04-04 04:23:30 +08:00
|
|
|
"currentlyInRoom" boolean
|
2023-03-17 00:56:32 +08:00
|
|
|
);
|
2023-04-06 00:56:22 +08:00
|
|
|
--CREATE INDEX "idx_user_breakoutRoom_userId" ON "user_breakoutRoom"("userId");
|
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
|
|
|
|
2023-04-06 00:56:22 +08:00
|
|
|
CREATE TABLE "user_connectionStatus" (
|
|
|
|
"userId" varchar(50) PRIMARY KEY REFERENCES "user"("userId") ON DELETE CASCADE,
|
|
|
|
"meetingId" varchar(100) REFERENCES meeting("meetingId"),
|
|
|
|
"status" varchar(15),
|
|
|
|
"statusUpdatedAt" timestamp,
|
|
|
|
"connectionAliveAt" timestamp
|
|
|
|
);
|
|
|
|
create index "idx_user_connectionStatus_meetingId" on "user_connectionStatus"("meetingId");
|
|
|
|
|
|
|
|
--CREATE OR REPLACE VIEW "v_user_connectionStatus" AS
|
|
|
|
--SELECT u."meetingId", u."userId", uc.status, uc."statusUpdatedAt", uc."connectionAliveAt",
|
|
|
|
--CASE WHEN "statusUpdatedAt" < current_timestamp - INTERVAL '20 seconds' THEN TRUE ELSE FALSE END AS "clientNotResponding"
|
|
|
|
--FROM "user" u
|
|
|
|
--LEFT JOIN "user_connectionStatus" uc ON uc."userId" = u."userId";
|
|
|
|
|
2023-03-29 20:55:41 +08:00
|
|
|
-- ===================== CHAT TABLES
|
|
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
);
|
2023-04-01 04:46:17 +08:00
|
|
|
CREATE INDEX "idx_chat_meetingId" ON "chat"("meetingId");
|
2023-03-29 20:55:41 +08:00
|
|
|
|
|
|
|
CREATE TABLE "chat_user" (
|
|
|
|
"chatId" varchar(100),
|
|
|
|
"meetingId" varchar(100),
|
2023-04-06 00:56:22 +08:00
|
|
|
"userId" varchar(50),
|
2023-03-29 20:55:41 +08:00
|
|
|
"lastSeenAt" bigint,
|
2023-04-06 00:56:22 +08:00
|
|
|
"typingAt" timestamp,
|
2023-03-29 20:55:41 +08:00
|
|
|
CONSTRAINT "chat_user_pkey" PRIMARY KEY ("chatId","meetingId","userId"),
|
|
|
|
CONSTRAINT chat_fk FOREIGN KEY ("chatId", "meetingId") REFERENCES "chat"("chatId", "meetingId") ON DELETE CASCADE
|
|
|
|
);
|
2023-04-01 04:46:17 +08:00
|
|
|
CREATE INDEX "idx_chat_user_chatId" ON "chat_user"("chatId","meetingId");
|
2023-03-29 20:55:41 +08:00
|
|
|
|
2023-04-06 00:56:22 +08:00
|
|
|
CREATE OR REPLACE VIEW "v_user_typing_public" AS
|
|
|
|
SELECT "meetingId", "chatId", "userId", "typingAt",
|
|
|
|
CASE WHEN "typingAt" > current_timestamp - INTERVAL '5 seconds' THEN true ELSE false END AS "isCurrentlyTyping"
|
|
|
|
FROM chat_user
|
|
|
|
WHERE "chatId" = 'MAIN-PUBLIC-GROUP-CHAT';
|
|
|
|
|
|
|
|
|
2023-03-29 20:55:41 +08:00
|
|
|
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
|
|
|
|
);
|
2023-04-01 04:46:17 +08:00
|
|
|
CREATE INDEX "idx_chat_message_chatId" ON "chat_message"("chatId","meetingId");
|
2023-03-29 20:55:41 +08:00
|
|
|
|
|
|
|
CREATE OR REPLACE VIEW "v_chat" AS
|
2023-04-03 21:46:47 +08:00
|
|
|
SELECT "user"."userId",
|
2023-03-29 20:55:41 +08:00
|
|
|
chat."meetingId",
|
|
|
|
chat."chatId",
|
2023-03-29 23:06:48 +08:00
|
|
|
chat_with."userId" AS "participantId",
|
2023-03-29 20:55:41 +08:00
|
|
|
count(DISTINCT cm."messageId") "totalMessages",
|
2023-04-04 04:23:30 +08:00
|
|
|
sum(CASE WHEN cm."senderId" != "user"."userId" and cm."createdTime" > coalesce(cu."lastSeenAt",0) THEN 1 ELSE 0 end) "totalUnread",
|
2023-04-06 00:56:22 +08:00
|
|
|
CASE WHEN chat."access" = 'PUBLIC_ACCESS' THEN true ELSE false end public
|
2023-03-29 20:55:41 +08:00
|
|
|
FROM "user"
|
|
|
|
LEFT JOIN "chat_user" cu ON cu."meetingId" = "user"."meetingId" AND cu."userId" = "user"."userId"
|
2023-04-06 00:56:22 +08:00
|
|
|
--now it will always add chat_user for public chat onUserJoin
|
|
|
|
--JOIN "chat" ON "user"."meetingId" = chat."meetingId" AND (cu."chatId" = chat."chatId" OR chat."chatId" = 'MAIN-PUBLIC-GROUP-CHAT')
|
|
|
|
JOIN "chat" ON "user"."meetingId" = chat."meetingId" AND cu."chatId" = chat."chatId"
|
2023-03-29 23:06:48 +08:00
|
|
|
LEFT JOIN "chat_user" chat_with ON chat_with."meetingId" = chat."meetingId" AND chat_with."chatId" = chat."chatId" AND chat."chatId" != 'MAIN-PUBLIC-GROUP-CHAT' AND chat_with."userId" != cu."userId"
|
2023-03-29 20:55:41 +08:00
|
|
|
LEFT JOIN chat_message cm ON cm."meetingId" = chat."meetingId" AND cm."chatId" = chat."chatId"
|
2023-04-03 21:46:47 +08:00
|
|
|
GROUP BY "user"."userId", chat."meetingId", chat."chatId", chat_with."userId";
|
2023-03-29 20:55:41 +08:00
|
|
|
|
|
|
|
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
|
2023-04-14 21:58:37 +08:00
|
|
|
JOIN chat_user cu ON cu."meetingId" = cm."meetingId" AND cu."chatId" = cm."chatId"
|
|
|
|
WHERE cm."chatId" != 'MAIN-PUBLIC-GROUP-CHAT';
|
2023-03-29 20:55:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
2023-04-01 04:46:17 +08:00
|
|
|
--============ Presentation / Annotation
|
2023-03-29 20:55:41 +08:00
|
|
|
|
|
|
|
|
2023-04-01 04:46:17 +08:00
|
|
|
CREATE TABLE "pres_presentation" (
|
|
|
|
"presentationId" varchar(100) PRIMARY KEY,
|
|
|
|
"meetingId" varchar(100) REFERENCES "meeting"("meetingId") ON DELETE CASCADE,
|
|
|
|
"current" boolean,
|
|
|
|
"downloadable" boolean,
|
|
|
|
"removable" boolean
|
|
|
|
);
|
|
|
|
CREATE INDEX "idx_pres_presentation_meetingId" ON "pres_presentation"("meetingId");
|
|
|
|
|
2023-04-06 00:56:22 +08:00
|
|
|
CREATE TABLE "pres_page" (
|
2023-04-01 04:46:17 +08:00
|
|
|
"pageId" varchar(100) PRIMARY KEY,
|
|
|
|
"presentationId" varchar(100) REFERENCES "pres_presentation"("presentationId") ON DELETE CASCADE,
|
|
|
|
"num" integer,
|
|
|
|
"urls" TEXT,
|
|
|
|
"current" boolean,
|
|
|
|
"xOffset" NUMERIC,
|
|
|
|
"yOffset" NUMERIC,
|
|
|
|
"widthRatio" NUMERIC,
|
|
|
|
"heightRatio" NUMERIC
|
|
|
|
);
|
|
|
|
CREATE INDEX "idx_pres_page_presentationId" ON "pres_page"("presentationId");
|
|
|
|
|
2023-04-06 00:56:22 +08:00
|
|
|
CREATE TABLE "pres_annotation" (
|
2023-04-01 04:46:17 +08:00
|
|
|
"annotationId" varchar(100) PRIMARY KEY,
|
|
|
|
"pageId" varchar(100) REFERENCES "pres_page"("pageId") ON DELETE CASCADE,
|
2023-04-06 00:56:22 +08:00
|
|
|
"userId" varchar(50),
|
2023-04-01 04:46:17 +08:00
|
|
|
"annotationInfo" TEXT,
|
2023-04-03 21:46:47 +08:00
|
|
|
"lastHistorySequence" integer,
|
2023-04-01 04:46:17 +08:00
|
|
|
"lastUpdatedAt" timestamp DEFAULT now()
|
|
|
|
);
|
|
|
|
CREATE INDEX "idx_pres_annotation_pageId" ON "pres_annotation"("pageId");
|
2023-04-04 04:23:30 +08:00
|
|
|
CREATE INDEX "idx_pres_annotation_updatedAt" ON "pres_annotation"("pageId","lastUpdatedAt");
|
2023-04-01 04:46:17 +08:00
|
|
|
|
2023-04-06 00:56:22 +08:00
|
|
|
CREATE TABLE "pres_annotation_history" (
|
2023-04-01 04:46:17 +08:00
|
|
|
"sequence" serial PRIMARY KEY,
|
|
|
|
"annotationId" varchar(100),
|
|
|
|
"pageId" varchar(100) REFERENCES "pres_page"("pageId") ON DELETE CASCADE,
|
2023-04-06 00:56:22 +08:00
|
|
|
"userId" varchar(50),
|
2023-04-01 04:46:17 +08:00
|
|
|
"annotationInfo" TEXT
|
|
|
|
-- "lastUpdatedAt" timestamp DEFAULT now()
|
|
|
|
);
|
|
|
|
CREATE INDEX "idx_pres_annotation_history_pageId" ON "pres_annotation"("pageId");
|
|
|
|
|
2023-04-06 00:56:22 +08:00
|
|
|
CREATE VIEW "v_pres_annotation_curr" AS
|
2023-04-01 04:46:17 +08:00
|
|
|
SELECT p."meetingId", pp."presentationId", pa.*
|
|
|
|
FROM pres_presentation p
|
|
|
|
JOIN pres_page pp ON pp."presentationId" = p."presentationId"
|
|
|
|
JOIN pres_annotation pa ON pa."pageId" = pp."pageId"
|
2023-04-06 00:56:22 +08:00
|
|
|
WHERE p."current" IS true
|
|
|
|
AND pp."current" IS true;
|
2023-04-01 04:46:17 +08:00
|
|
|
|
2023-04-06 00:56:22 +08:00
|
|
|
CREATE VIEW "v_pres_annotation_history_curr" AS
|
2023-04-01 04:46:17 +08:00
|
|
|
SELECT p."meetingId", pp."presentationId", pah.*
|
|
|
|
FROM pres_presentation p
|
|
|
|
JOIN pres_page pp ON pp."presentationId" = p."presentationId"
|
|
|
|
JOIN pres_annotation_history pah ON pah."pageId" = pp."pageId"
|
2023-04-06 00:56:22 +08:00
|
|
|
WHERE p."current" IS true
|
|
|
|
AND pp."current" IS true;
|
2023-04-01 04:46:17 +08:00
|
|
|
|
|
|
|
CREATE TABLE "pres_page_writers" (
|
|
|
|
"pageId" varchar(100) REFERENCES "pres_page"("pageId") ON DELETE CASCADE,
|
|
|
|
"userId" varchar(50) REFERENCES "user"("userId") ON DELETE CASCADE,
|
|
|
|
"changedModeOn" bigint,
|
|
|
|
CONSTRAINT "pres_page_writers_pkey" PRIMARY KEY ("pageId","userId")
|
|
|
|
);
|
|
|
|
create index "idx_pres_page_writers_userID" on "pres_page_writers"("userId");
|
|
|
|
|
|
|
|
CREATE OR REPLACE VIEW "v_pres_page_writers" AS
|
|
|
|
SELECT
|
|
|
|
u."meetingId",
|
|
|
|
"pres_presentation"."presentationId",
|
|
|
|
"pres_page_writers" .*,
|
2023-04-06 00:56:22 +08:00
|
|
|
CASE WHEN pres_presentation."current" IS true AND pres_page."current" IS true THEN true ELSE false END AS "isCurrentPage"
|
2023-04-01 04:46:17 +08:00
|
|
|
FROM "pres_page_writers"
|
|
|
|
JOIN "user" u ON u."userId" = "pres_page_writers"."userId"
|
|
|
|
JOIN "pres_page" ON "pres_page"."pageId" = "pres_page_writers"."pageId"
|
|
|
|
JOIN "pres_presentation" ON "pres_presentation"."presentationId" = "pres_page"."presentationId" ;
|
|
|
|
|
2023-04-04 04:23:30 +08:00
|
|
|
CREATE TABLE "pres_page_cursor" (
|
|
|
|
"pageId" varchar(100) REFERENCES "pres_page"("pageId") ON DELETE CASCADE,
|
|
|
|
"userId" varchar(50) REFERENCES "user"("userId") ON DELETE CASCADE,
|
|
|
|
"xPercent" numeric,
|
|
|
|
"yPercent" numeric,
|
|
|
|
"lastUpdatedAt" timestamp DEFAULT now(),
|
|
|
|
CONSTRAINT "pres_page_cursor_pkey" PRIMARY KEY ("pageId","userId")
|
|
|
|
);
|
|
|
|
create index "idx_pres_page_cursor_pageId" on "pres_page_cursor"("pageId");
|
|
|
|
create index "idx_pres_page_cursor_userID" on "pres_page_cursor"("userId");
|
|
|
|
create index "idx_pres_page_cursor_lastUpdatedAt" on "pres_page_cursor"("pageId","lastUpdatedAt");
|
|
|
|
|
2023-04-06 00:56:22 +08:00
|
|
|
CREATE VIEW "v_pres_page_cursor" AS
|
2023-04-04 04:49:24 +08:00
|
|
|
SELECT pres_presentation."meetingId", pres_page."presentationId", c.*,
|
2023-04-06 00:56:22 +08:00
|
|
|
CASE WHEN pres_presentation."current" IS true AND pres_page."current" IS true THEN true ELSE false END AS "isCurrentPage"
|
2023-04-04 04:23:30 +08:00
|
|
|
FROM pres_page_cursor c
|
|
|
|
JOIN pres_page ON pres_page."pageId" = c."pageId"
|
|
|
|
JOIN pres_presentation ON pres_presentation."presentationId" = pres_page."presentationId";
|
2023-04-01 04:46:17 +08:00
|
|
|
|