-
Notifications
You must be signed in to change notification settings - Fork 1
Database Schema
Dillon Rice edited this page Apr 30, 2020
·
17 revisions
users
| column Name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
email |
string | not null, indexed, unique |
full_name |
string | not null |
display_name |
string | allow null |
title |
string | allow null |
user_description |
text | allow null |
user_status |
string | allow null |
user_avatar_url |
string | not null |
password_digest |
string | not null |
session_token |
string | not null, indexed, unique |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- has many
messages - has many
conversationsthroughmemberships - has many
attachments - has many
reactions
messages
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
body |
text | not null |
author_id |
integer | not null, indexed, foreign key |
recipient_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
author_idis a foreign key belonging to theuserstable. -
recipient_id is a foreign key belonging to theconversations` table. -
messagesbelong to bothusersandconversations - has many
reactions - has many
attachments
conversations
| column name | data type | details |
|---|---|---|
id |
integer | not null, primary key |
name |
string | not null, unique (would not be unique in the case of multiple workspaces) |
description |
text | allow null |
owner_id |
integer | indexed, foreign key |
is_private? |
boolean | not null |
playlist_url |
string | not if type == "channel" |
restricted_playlist |
boolean | allow null. If true, only admins can edit playlist |
type |
text | includes "direct_message", "group_message", or "channel", not null |
created_at |
datetime | not null |
updated_at |
datetime | not null |
-
owner_idis a foreign key of theuserstable - has many
messages - has many members users
memberships
memberships
| column name | data type | details |
|---|---|---|
id |
integer | not null, indexed, primary key |
member_id |
integer | not null, indexed, foreign key |
conversation_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- belongs to
usersthrough foreign keymember_id - belongs to
conversationsthrough foreign keyconversation_id
admins
| column name | data type | details |
|---|---|---|
id |
integer | not null, indexed, primary key |
admin_user_id |
integer | not null, indexed, foreign key |
conversation_id |
integer | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- belongs to
usersthrough foreign keyadmin_user_id - belongs to
conversationsthrough foreign keyconversation_id