Skip to content
PlasmaNuke edited this page Jan 11, 2024 · 5 revisions

users

column name data type details
id bigint not null, primary key
username string not null, indexed, unique
email string not null, indexed, unique
img_url string
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
  • has_many :tracks
  • has_many :likes
  • has_many :comments

tracks

column name data type details
id bigint not null, primary key
artist_id bigint not null, indexed, foreign key
title string not null, indexed
description text
genre string
album_id bigint indexed, foreign key
source_url string not null, indexed, unique
image_url string
file_type string not null
duration float not null
created_at datetime not null
updated_at datetime not null
  • artist_id references users
  • album_id references albums
  • index on artist_id
  • index on album_id
  • index on title
  • index on source_url, unique: true
  • belongs_to :artist
  • belongs_to :album
  • has_many :track_likes, foreign_key: :track_id
  • has_many :playlist_tracks, foreign_key: :track_id
  • has_many :playlists, through: :playlist_tracks, source: :playlist
  • has_many :likes, through: :track_likes, foreign_key: :track_id
  • has_many :likers, through :likes

albums

column name data type details
id bigint not null, primary key
artist_id bigint not null, indexed, foreign key
title string not null, indexed
description text
genre string
image_url string
release_date datetime not null
created_at datetime not null
updated_at datetime not null
  • artist_id references users
  • index on artist_id
  • index on title
  • has_many :tracks

playlists

column name data type details
id bigint not null, primary key
title string not null, indexed
description text
genre string
image_url string
created_at datetime not null
updated_at datetime not null
  • artist_id references users
  • index on artist_id
  • index on track_id
  • index on title
  • has_many :playlist_tracks
  • has_many :tracks, through: :playlist_tracks, source: :track
  • has_many :artists, through: :tracks

playlist_tracks

column name data type details
id bigint not null, primary key
playlist_id bigint not null, indexed, foreign key
track_id bigint not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • playlist_id references playlists
  • track_id references tracks
  • index on playlist_id
  • index on track_id
  • belongs_to :playlist
  • belongs_to :track

comments

column name data type details
id bigint not null, primary key
commenter_id bigint not null, indexed, foreign key
track_id bigint not null, indexed, foreign key
timestamp float not null
content text not null
created_at datetime not null
updated_at datetime not null
  • commenter_id references users
  • track_id references tracks
  • belongs_to :commenter
  • belongs_to :track

track_likes

column name data type details
id bigint not null, primary key
liker_id bigint not null, indexed, foreign key
track_id bigint not null, indexed, foreign key
created_at datetime not null
updated_at datetime not null
  • liker_id references users
  • track_id references tracks
  • belongs_to :liker
  • belongs_to :track

Clone this wiki locally