schema - Neminem1203/Me-Cube GitHub Wiki

Schema

users

column 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 string not null, indexed, unique
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

videos

column data type details
id integer not null, primary key
title string not null, indexed
video_url text not null
description text not null
creator_id integer not null, indexed, foreign key
created at datetime not null
updated at datetime not null
  • index on title
  • index on creator_id
  • creator_id references users
  • :title, uniqueness: {scope: :creator_id} in models

likes

column data type details
id integer not null, primary key
like_dislike boolean not null
user_id integer not null, indexed
likeable_id integer not null, indexed
likeable_type string not null, indexed
  • index on likeable_id
  • index on likeable_type
  • index on user_id
  • user_id refers to users
  • likeable_type can be comments or videos
  • :user_id, uniqueness: {scope: [:likeable_id, :likeable_type]} in models

comments

column data type details
id integer not null, primary
comment text not null
commenter_id integer not null, indexed, foreign key
commentable_id integer not null, indexed
commentable_type string not null ,indexed
created_at datetime not null
updated_at datetime not null
  • index on video_id
  • index on commenter_id
  • commenter_id references users
  • commentable_type can be comments or videos
  • :commenter_id, uniqueness: {scope: [:commentable_id, :commentable_type]} in models
⚠️ **GitHub.com Fallback** ⚠️