-
Notifications
You must be signed in to change notification settings - Fork 8
schema
Phillip edited this page Dec 9, 2019
·
9 revisions
data type | column name | details |
---|---|---|
integer | id | not null, primary key |
string | username | not null |
integer | tag | not null |
string | not null | |
string | password_digest | not null |
string | session_token | not null |
string | image_url | |
datetime | created_at | not null |
datetime | updated_at | not null |
- index on
[username, tag], unique: true
- index on
email, unique: true
- index on
session_token, unique: true
data type | column name | details |
---|---|---|
integer | id | not null, primary key |
integer | owner_id | not null, foreign key |
string | name | not null |
text | description | not null |
boolean | is_private | not null, default: false |
string | invite_token | not null |
datetime | created_at | not null |
datetime | updated_at | not null |
-
owner_id
referencesusers
- index on
owner_id
with one channel and two equal members -
invite_token
is used for a permanent invitation link
data type | column name | details |
---|---|---|
integer | id | not null, primary key |
integer | server_id | not null, foreign key |
string | name | not null |
text | description | not null |
datetime | created_at | not null |
datetime | updated_at | not null |
-
server_id
referencesservers
- index on
server_id
data type | column name | details |
---|---|---|
integer | id | not null, primary key |
integer | channel_id | not null, foreign key |
integer | author_id | not null, foreign key |
text | body | not null |
datetime | created_at | not null |
datetime | updated_at | not null |
-
channel_id
referenceschannels
-
author_id
referencesusers
- index on
channel_id
- index on
author_id
data type | column name | details |
---|---|---|
integer | id | not null, primary key |
integer | server_id | not null, foreign key |
integer | user_id | not null, foreign key |
datetime | created_at | not null |
datetime | updated_at | not null |
-
server_id
referencesservers
-
user_id
referencesusers
- index on
[user_id, server_id], unique: true
data type | column name | details |
---|---|---|
integer | id | not null, primary key |
integer | server_id | not null, foreign key |
integer | invitee_id | foreign key |
string | token | not null |
datetime | expiry | not null |
datetime | created_at | not null |
datetime | updated_at | not null |
-
server_id
referencesservers
-
invitee_id
referencesusers
- index on
[invitee_id, server_id], unique: true
- index on
token, unique: true
- used for temporary invitations
- invitee_id used for private invitations; allow null for general invitations
-
servers#is_private
won't come into play until private servers are introduced - DMs will require more thought, since they are very similar to channels, but don't belong to a normal server
- Note the distinction between
servers#invite_token
andinvitations#token
. They are for permanent and temporary invitation, respectively