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_id
referencesusers
- 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_id
referencesusers
following_id
referencesusers
- 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_id
referencesusers
photo_id
referencesphotos
- 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_id
referencesusers
photo_id
referencesphotos
parent_comment_id
referencescomments
- index on
[:author_id, :photo_id, :parent_comment_id]