-
Notifications
You must be signed in to change notification settings - Fork 5
Database Schema
aguamenti edited this page Aug 18, 2018
·
23 revisions
- users
- permissions (joins)
- channels
- memberships (joins)
- direct_messages
| Column Name | Data Type | Details |
|---|---|---|
id |
integer | not null, primary key |
email |
string | not null, indexed, unique |
display_name |
string | not null |
password_digest |
string | not null |
session_token |
string | not null, indexed, unique |
- index on
email,unique: true - index on
session_token,unique: true - AWS will host profile pictures, so
img_urlunnecessary
| Column Name | Data Type | Details |
|---|---|---|
id |
integer | not null, primary key |
user_id |
integer | not null |
channel_id |
integer | not null |
-
user_idreferencesusers(belongs_to :user) -
channel_idreferenceschannels(belongs_to :channel) - index on
:channel_id - index on
[:user_id, :channel_id], unique: true
| Column Name | Data Type | Details |
|---|---|---|
id |
integer | not null, primary key |
title |
string | not null |
private |
boolean | not null |
is_dm |
boolean | not null |
has_many :permissionshas_many :permitted_users, through: permissions, source: userhas_many :messages, as: :messageable
| Column Name | Data Type | Details |
|---|---|---|
| id | integer | not null, primary key |
| body | text | not null |
| author_id | integer | not null, indexed, foreign key |
| messageable_type | string | not null |
| messageable_id | integer | not null, foreign key |
-
author_idreferencesusers(belongs_to :user) -
belongs_to messageable, polymorphic: true-
messageable_typeis "channel" -
messageable_idreferences achannel
-
| Column Name | Data Type | Details |
|---|---|---|
created_at |
datetime | not null |
updated_at |
datetime | not null |