Schema - npartovi/Destructables GitHub Wiki
Articles
| Column | Type | Details |
|---|---|---|
id |
integer | not null, primary key |
title |
string | not null, unique,indexed |
body |
string | not null |
img_url |
string | not null |
user_id |
integer | not null, indexed, foreign_key |
created_at |
dateTime | not null |
update_at |
dateTime | not null |
- index on
[:user_id, :title], unique: true user_idreferencesusers- belongs_to user
- has_many comments
- has_many favorites
- has_many steps
- has_many medias
Users
| Column | Type | Details |
|---|---|---|
id |
integer | not null, primary key |
username |
string | not null, unique, indexed |
email |
string | not null, unique, indexed |
profile_img |
string | not null |
password_digest |
string | not null |
session_token |
string | not null, unique, indexed |
created_at |
dateTime | not null |
update_at |
dateTime | not null |
- has_many articles
- has_many comments
- has_many liked_articles
Comments
| Column | Type | Details |
|---|---|---|
id |
integer | not null, primary key |
body |
string | not null |
user_id |
integer | not null, indexed, foreign_key |
article_id |
integer | not null, indexed, foreign_key |
created_at |
dateTime | not null |
update_at |
dateTime | not null |
user_idreferencesusersarticle_idreferencesarticles- belongs_to user
- belongs_to article
Steps
| Column | Type | Details |
|---|---|---|
id |
integer | not null, primary key |
ord |
integer | not null, unique |
title |
string | not null |
body |
string | not null |
article_id |
integer | not null, indexed, foreign_key |
created_at |
dateTime | not null |
update_at |
dateTime | not null |
article_idreferencesarticle- belongs_to article
- has_one media
Medias
| Column | Type | Details |
|---|---|---|
id |
integer | not null, primary key |
article_id |
integer | not_null, indexed, foreign_key |
step_id |
integer | not null, indexed, foreign_key, unique |
media_url |
string | |
created_at |
dateTime | not null |
update_at |
dateTime | not null |
article_idreferencesarticlesstep_idreferencessteps- belongs_to article
- belongs_to step
Favorites
| Column | Type | Details |
|---|---|---|
id |
integer | not null, primary key |
article_id |
integer | not null, indexed, foreign_key |
user_id |
integer | not null, indexed, foreign_key |
created_at |
dateTime | not null |
update_at |
dateTime | not null |
article_idreferencesarticlesuser_idreferencesusers- index on
[:article_id, :user_id], unique: true - belongs_to article
- belongs_to user