You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CREATE TABLE
public.Profile (
id TEXTPRIMARY KEY DEFAULT gen_random_uuid(),
userId TEXT,
name TEXT,
imgUrl TEXT,
email TEXT,
createdAt TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updatedAt TIMESTAMP WITH TIME ZONE DEFAULT now()
);
2. Table - 'Server':
Column Name
Data Type
Description
id
text
Primary key
name
text
Name of the server
imgUrl
text
Thumbnail
profileId
text
Owner of the server- It is a forign key of Profile(id)
inviteCode
text
Invite link for the server
createdAt
timestamp
Time of creation
updatedAt
timestamp
Last updated time
SQL code to create table
CREATE TABLE
public.Server (
id TEXTPRIMARY KEY DEFAULT gen_random_uuid(),
name TEXT,
imgUrl TEXT,
inviteCode TEXT,
profileId TEXT,
createdAt TIMESTAMP WITHOUT TIME ZONE default current_timestamp,
updatedAt TIMESTAMP WITHOUT TIME ZONE default now(),
FOREIGN KEY (profileId) REFERENCESpublic.Profile (id)
);
3. Table - 'Channel':
Column Name
Data Type
Description
id
text
Primary key
name
text
Name of the channel
type
channelType
It is a enum of type channel type
serverId
text
Server id- It is a forign key of Server(id)
profileId
text
Profile id of admin - It is a forign key
createdAt
timestamp
Time of creation
updatedAt
timestamp
Last updated time
SQL code to create table
CREATE TABLE
Channel (
id TEXTPRIMARY KEY DEFAULT gen_random_uuid(),
name text,
type channeltype,
serverId text,
profileId text,
createdAt TIMESTAMP WITHOUT TIME ZONE default current_timestamp,
updatedAt TIMESTAMP WITHOUT TIME ZONE default now(),
FOREIGN KEY (profileId) REFERENCESpublic.Profile (id),
FOREIGN KEY (serverId) REFERENCESpublic.Server (id)
);
3. Table - 'Member':
Column Name
Data Type
Description
id
text
Primary key
role
memberrole
It is a enum of type member role
serverId
text
Server id- It is a forign key of Server(id)
profileId
text
Profile id of admin - It is a forign key
createdAt
timestamp
Time of creation
updatedAt
timestamp
Last updated time
SQL code to create table
CREATE TABLE
Member (
id TEXTPRIMARY KEY DEFAULT gen_random_uuid(),
role memberrole,
serverId text,
profileId text,
createdAt TIMESTAMP WITHOUT TIME ZONE default current_timestamp,
updatedAt TIMESTAMP WITHOUT TIME ZONE default now(),
FOREIGN KEY (profileId) REFERENCESpublic.Profile (id),
FOREIGN KEY (serverId) REFERENCESpublic.Server (id)
);
3. Table - 'Message':
Column Name
Data Type
Description
id
text
Primary key
content
text
Content of the message
fileUrl
text
Attachment url (nullable)
memberId
text
Member id - It is a foreign key for Member(id)
channelId
text
Channel id - It is a forign key for Channel(id)
deleted
boolean
A boolean value to check if message is deleted
createdAt
timestamp
Time of creation
updatedAt
timestamp
Last updated time
SQL code to create table
CREATE TABLE
Message (
id TEXTPRIMARY KEY DEFAULT gen_random_uuid(),
CONTENT text,
fileUrl TEXT,
memberId TEXT ,
channelId TEXT,
deleted BOOLEAN,
createdAt TIMESTAMP WITHOUT TIME ZONE default current_timestamp,
updatedAt TIMESTAMP WITHOUT TIME ZONE default now(),
FOREIGN KEY (channelId) REFERENCESpublic.Channel (id),
FOREIGN KEY (memberId) REFERENCESpublic.Member (id)
);
4. Table - 'Conversation':
Column Name
Data Type
Description
id
text
Primary key
memberOneId
text
Sender Member Id - Foreign key for Member(id)
memberTwoId
text
Receiver Member Id - Foreign key for Member(id)
createdAt
timestamp
Time of creation
SQL code to create Table
CREATE TABLE
Conversation (
id TEXTPRIMARY KEY DEFAULT gen_random_uuid(),
memberOneId TEXT ,
memberTwoId TEXT,
createdAt TIMESTAMP WITHOUT TIME ZONE default current_timestamp,
FOREIGN KEY (memberTwoId) REFERENCESpublic.Member (id),
FOREIGN KEY (memberOneId) REFERENCESpublic.Member (id)
);
5. Table - 'DirectMessage':
Column Name
Data Type
Description
id
text
Primary key
content
text
Content of the message
fileUrl
text
Attachment url (nullable)
memberId
text
Sender Id - foreign keys for Member(id)
conversationId
text
Converastion Id - Foreign key for Conversation(id)
deleted
boolean
A boolean value to check if message is deleted
createdAt
timestamp
Time of creation
updatedAt
timestamp
Last updated time
CREATE TABLE
DirectMessage (
id TEXTPRIMARY KEY DEFAULT gen_random_uuid(),
CONTENT TEXT,
fileUrl TEXT,
memberId TEXT,
conversationId TEXT,
deleted BOOLEAN,
createdAt TIMESTAMP WITHOUT TIME ZONE default current_timestamp,
updatedAt TIMESTAMP WITHOUT TIME ZONE default now(),
FOREIGN KEY (memberId) REFERENCES Member (id),
FOREIGN KEY (conversationId) REFERENCES Conversation (id)
);