schema - ZiluoH/Thiscord GitHub Wiki

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

servers

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

channels

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

messages

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