schema - nooccarr/perfect-pixel 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 | 
datetime | not null, indexed, unique | 
profile_url | 
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 
photos
| column_name | data_type | details | 
|---|---|---|
id | 
integer | not null, primary key, indexed | 
title | 
string | not null, indexed | 
photographer_id | 
integer | not null, foreign key, indexed | 
image_url | 
string | |
created_at | 
datetime | not null | 
updated_at | 
datetime | not null | 
photographer_idreferencesusers- index on 
title - index on 
photographer_id 
follows
| column_name | data_type | details | 
|---|---|---|
id | 
integer | not null, primary key, indexed | 
follower_id | 
integer | not null, foreign key, indexed, unique | 
following_id | 
integer | not null, foreign key, indexed, unique | 
created_at | 
datetime | not null | 
updated_at | 
datetime | not null | 
follower_idreferencesusersfollowing_idreferencesusers- index on 
[:follower_id, :following_id], unique: true 
likes
| column_name | data_type | details | 
|---|---|---|
id | 
integer | not null, primary key, indexed | 
liker_id | 
integer | not null, foreign key, unique, indexed | 
photo_id | 
integer | not null, foreign key, unique, indexed | 
created_at | 
datetime | not null | 
updated_at | 
datetime | not null | 
liker_idreferencesusersphoto_idreferencesphotos- index on 
[:liker_id, :photo_id], unique: true 
comments
| column_name | data_type | details | 
|---|---|---|
id | 
integer | not null, primary key, indexed | 
comment | 
text | not null | 
author_id | 
integer | not null, foreign key, indexed | 
photo_id | 
integer | not null, foreign key, indexed | 
parent_comment_id | 
integer | foreign key, indexed | 
image_url | 
string | |
created_at | 
datetime | not null | 
updated_at | 
datetime | not null | 
author_idreferencesusersphoto_idreferencesphotosparent_comment_idreferencescomments- index on 
[:author_id, :photo_id, :parent_comment_id]