Skip to content

Database Schema

greathmaster edited this page Mar 6, 2020 · 9 revisions

Database Schema

users

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

messages

column name data type details
id integer not null, primary key
content string not null
channel_id integer not null, indexed
sender_id integer not null, indexed
created_at datetime not null
updated_at datetime not null
  • sender_id references users
  • channel_id references channels

users_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, foreign key
created_at datetime not null
updated_at datetime not null
  • user_id references users
  • channel_id references channels
  • index on [:channel_id, :user_id], unique: true

channels

column_name data_type details
id integer not null, primary key
name text not null
owner_id integer not null, indexed, foreign key
private boolean [true, false]: default: false
created_at datetime not null
updated_at datetime not null
  • owner_id references users

workspaces

column_name data_type details
id integer not null, primary key
name text not null
url text not null
owner_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • owner_id references users

workspaces_channels

column_name data_type details
id integer not null, primary key
workspace_id integer not null, indexed, foreign key
channel_id integer not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • workspace_id references workspaces
  • channel_id references channels
  • index on [:workspace_id, :user_id], unique: true

Clone this wiki locally