Schema - AlbertgitC/instafeeds GitHub Wiki
Database Schema
users
| column name | data type | details |
|---|---|---|
| id | integer | not null, primary key |
| username | string | not null, indexed, unique |
| string | not null, indexed, unique | |
| password_digest | string | not null |
| session_token | string | not null, indexed, unique |
| website | string | |
| bio | text | |
| 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
feeds
| column name | data type | details |
|---|---|---|
| id | integer | not null, primary key |
| body | text | |
| author_id | integer | not null, indexed, foreign key |
| created_at | datetime | not null |
| updated_at | datetime | not null |
author_idreferencesusers- index on
author_id attached :photo
comments
| column name | data type | details |
|---|---|---|
| id | integer | not null, primary key |
| body | text | not null |
| feed_id | integer | not null, indexed, foreign key |
| author_id | integer | not null, foreign key |
| created_at | datetime | not null |
| updated_at | datetime | not null |
feed_idreferencesfeedsauthor_idreferencesusers
likes
| column name | data type | details |
|---|---|---|
| id | integer | not null, primary key |
| likeable_id | integer | not null, indexed, foreign key |
| likeable_type | string | not null, indexed |
| author_id | integer | not null, foreign key |
| created_at | datetime | not null |
| updated_at | datetime | not null |
- polymorphic table,
likeable_type=feedorcomment likeable_idreferencesfeedsorcommentsauthor_idreferencesusers- index on
[:likeable_id, :likeable_type, :author_id], unique: true
follows
| column name | data type | details |
|---|---|---|
| id | integer | not null, primary key |
| user_id | integer | not null, indexed, foreign key |
| follower_id | integer | not null, indexed, foreign key |
| created_at | datetime | not null |
| updated_at | datetime | not null |
user_idreferencesusersfollower_idreferencesusers