Schema - mmbarness/recordcollector GitHub Wiki

## ### Documentation

Schema

Users

Column Name Data Type Details index?
id integer not null, primary key yes
username string not null, unique yes
email string not null, unique yes
password_digest string not null no
session_token string not null, unique yes
album_id integer not null, foreign key for albums purchased by a user, unique yes
created_at timestamp not null no
updated_at timestamp not null no
  • index on username, unique: true
  • index on email, unique: true`
  • index on session_token, unique: true
  • album_id references albums

Artists

Column Name Data Type Details index?
id integer not null, primary key yes
name string not null, name of artist, unique yes
location string not null, where artist is based no
  • index on title, unique: true

Albums

Column Name Data Type Details index?
id integer not null, primary key yes
title string not null, name of the album no
description string album description, supplied by artist/label no
credits string album credits no
artist_id integer not null, foreign key for artist that released the album yes
created_at timestamp --- yes
updated_at timestamp --- yes
  • index on artist_id
  • artist_id references artists

Tracks

Column Name Data Type Details index?
id integer not null, primary key yes
title string not null, name of the track no
track_number integer not null, position of track w/r/t the album, unique no
artist_id integer not null, foreign key for artist that released the track yes
album_id integer not null, foreign key for album track belongs to yes
created_at timestamp --- yes
updated_at timestamp --- yes
  • index on artist_id
  • artist_id references artists
  • index on album_id
  • album_id references albums

Cart Items

Column Name Data Type Details Index?
id integer not null, primary key yes
user_id integer not null, user cart belongs to yes
album_id integer album in the user's cart, unique yes
created_at timestamp --- no
updated_at timestamp --- no
  • index on user_id
  • user_id references users
  • index on album_id
  • album_id references albums

Active Storage Attachments

Column Name Data Type Details Index?
name string not null no
record_type integer not null yes
record_id integer not null yes
blob_id integer not null no
created_at timestamp --- no
  • index on blob_id
  • blob_id references Active Storage Blobs
  • index on record_type
  • index on record_id
  • index on name

Active Storage Blobs

Column Name Data Type Details Index?
key string not null yes
filename string not null no
content_type string not null no
metadata text --- no
byte_size bigint --- no
checksum string --- no
created_at datetime --- no
  • index on key