Skip to content

Database Schema

Tan Loc Phan edited this page Feb 6, 2018 · 15 revisions

users

column name data type details
id integer not null, primary key
username string not null, indexed, unique
email string not null, indexed, unique
pic_url string not null
password_digest string not null
session_token string not null, indexed, unique
created_at datetime not null
updated_at datetime not null

recipes

column name data type details
id integer not null, primary key
title string not null
author_id integer not null
img_url string not null
rating integer
difficulty string not null
preparation_min integer
baking_min integer
resting_min integer
ingredients string not null
text text not null
created_at datetime not null
updated_at datetime not null

Note: rich text editor for text?


stories

column name data type details
id integer not null, primary key
title string not null
author_id integer not null, foreign key
img_url string not null
text text
created_at datetime not null
updated_at datetime not null

Note: rich text editor for text?


comments

column name data type details
id integer not null, primary key
commentable_id integer not null, foreign key, polymorphic
comentable_type string not null, polymorphic
author_id integer not null, foreign key
parent_comment_id integer
text string not null
img_url string
like_num integer
created_at datetime not null
updated_at datetime not null

Note: Add index as [commentable_type, commentable_id]


Bonus (for later)

videos

column name data type details
id integer not null, primary key
title string not null
video_url string not null
created_at datetime not null
updated_at datetime not null

Note: video_url is Vimeo/Youtube

Clone this wiki locally