-
Notifications
You must be signed in to change notification settings - Fork 0
Schema
Yan Rivera edited this page Oct 26, 2022
·
25 revisions
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
username |
string | not null, indexed, unique |
email |
string | not null, indexed, unique |
password_digest |
string | not null |
session_token |
string | not null, indexed, unique |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
username, unique: true
- index on
email, unique: true
- index on
session_token, unique: true
has_many messages
has_many workspace_subscriptions
has_many direct_message_subscriptions
has_many channel_subscriptions
has_many conversations, through: direct_message_subscriptions
has_many workspaces, through: workspace_subscriptions
has_many channels, through: channel_subscriptions
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
name |
string | not null, indexed, unique |
owner_id |
bigint | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
name, unique: true
- index on
owner_id
-
owner_id
referencesusers
has_many users, through: workspace_subscriptions
has_many channels
has_many direct_messages
belongs_to owner
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
user_id |
bigint | not null, indexed, foreign key |
workspace_id |
bigint | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
user_id
- index on
workspace_id
-
user_id
referencesusers
-
workspace_id
referencesworkspaces
belongs_to user
belongs_to workspace
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
content |
text | not null, indexed, unique |
author_id |
bigint | not null, indexed, foreign key |
messageable_id |
bigint | indexed |
messageable_type |
string | indexed |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
content, unique: true
- index on
author_id
- index on
messageable_id
- index on
messageable_type
-
author_id
referencesusers
belongs_to author
belongs_to messageable, polymorphic: true
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
workspace_id |
bigint | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
workspace_id
-
workspace_id
referencesworkspaces
belongs_to workspace
has_many user_direct_messages
has_many messages, as messageable
has_many users, through: direct_message_subscriptions
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
user_id |
bigint | not null, indexed, foreign key |
direct_message_id |
bigint | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
user_id
- index on
direct_message_id
-
user_id
referencesusers
-
direct_message_id
referencesdirect_messages
belongs_to user
belongs_to direct_messages
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
name |
text | not null, indexed, unique |
workspace_id |
bigint | not null, indexed, foreign key |
owner_id |
bigint | not null, indexed, foreign key |
description |
string | |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
name, unique: true
- index on
workspace_id
-
workspace_id
referencesworkspaces
has_many messages, as messageable
has_many users, through: channel_subscriptions
belongs_to workspace
belongs_to owner
column name | data type | details |
---|---|---|
id |
integer | not null, primary key |
user_id |
bigint | not null, indexed, foreign key |
channel_id |
bigint | not null, indexed, foreign key |
created_at |
datetime | not null |
updated_at |
datetime | not null |
- index on
user_id
- index on
channel_id
-
user_id
referencesusers
-
channel_id
referenceschannels
belongs_to user
belongs_to channel