Skip to content
saphknight edited this page Mar 21, 2019 · 10 revisions

Schema

users

column name data type details
id integer not null, primary key
username string not null
user_image_url string not null
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 email, unique: true
  • index on session_token, unique: true

workspaces

column name data type details
id integer not null, primary key
name string not null
url string not null, indexed, unique
created_at datetime not null
updated_at datetime not null
  • index on url, unique: true

channels

column name data type details
id integer not null, primary key
name string not null
description string not null
direct_message? boolean not null
workspace_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • workspace_id references workspaces
  • index on workspace_id

messages

column name data type details
id integer not null, primary key
body string not null
channel_id integer not null, indexed, foreign key
user_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • channel_id references channels
  • user_id references users
  • index on channel_id
  • index on user_id

Joins Tables

user_workspaces

column name data type details
id integer not null, primary key
user_id integer not null, indexed, foreign key
workspace_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • workspace_id references workspaces
  • index on [:user_id, :workspace_id], unique: true
  • index on user_id
  • index on workspace_id

user_channels

column name data type details
id integer not null, primary key
user_id integer not null, indexed, foreign key
channel_id integer not null, indexed
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • channel_id references channels
  • index on [:user_id, :channel_id], unique: true
  • index on user_id
  • index on channel_id
Clone this wiki locally