Schema - fjswayze/Shack GitHub Wiki
Postgres 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 |
profile_picture_id |
integer | not null |
status |
string | |
title |
string | |
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 | string | not null |
user_id | integer | not null, foreign key, indexed |
messageable_id | integer | not null, foreign key, indexed |
messageable_type | string | not null, foreign key, indexed |
parent_message_id | integer | foreign key, indexed |
body | string | not null |
created_at | datetime | not null |
updated_at | datetime | not null |
- index on
author_id
- index on
parent_message_id
author_id
referencesusers
parent_message_id
referencesmessages
[:messageable_id, :messageable_type], unique: true
polymorphically references either channels or direct_messages
channels
column name | data type | details |
---|---|---|
id | integer | not null, primary key |
name | string | not null |
description | string | |
private | boolean | |
admin_id | integer | |
created_at | datetime | not null |
updated_at | datetime | not null |
memberships
column name | data type | details |
---|---|---|
id | integer | not null, primary key |
user_id | integer | not null, foreign key, indexed |
memberable_id | integer | not null, foreign key, indexed |
memberable_type | string | not null, foreign key, indexed |
created_at | datetime | not null |
updated_at | datetime | not null |
user_id
referencesusers
[:memberable_id, :memberable_type], unique: true
polymorphically references either channels or direct_messages
direct_messages
column name | data type | details |
---|---|---|
id | integer | not null, primary key |
created_at | datetime | not null |
updated_at | datetime | not null |
profile_pictures
column name | data type | details |
---|---|---|
id | integer | not null, primary key |
url | string | not null |
user_id | integer | not null, indexed, foreign key |
user_id
referencesusers