Currently, a user can add a rating and add a review to a movie they have seen. I would like to allow a user to add more than one of these items because opinions change over time.
I also think we could condense the rating and the review into 1 record, similar to any other product review we'd write. This new kind of review would have a review.rating and a review.comment (as well as the usual timestamps).
In order to migrate the existing data, my first thoughts are:
if we trust that front end logic dictates possible data combinations, a user must have a movie screening for a review or a rating to be present, but a movie may or may not have either a rating or a review.
add a new integer column on the reviews table that we'll call rating
for each user, loop over all screenings
next if the movie has neither rating nor review
next if the movie has only a review (but log this somehow, maybe console putsing so we can see the data. we'll probably want to backfill it).
if the movie has a rating and a review, copy the rating over to the review.rating field
if the movie has only a rating, make a new review record, populating it with all of original rating data
backfill any reviews that are missing a rating
add null constraint to review.rating
drop the old ratings table
Code changes:
we have some queries like reviewed_movies and rated_movies that will require updating
we can delegate the rating through the review if we want to
front end changes are probably limited to the movie modal and show pages
Currently, a user can add a rating and add a review to a movie they have seen. I would like to allow a user to add more than one of these items because opinions change over time.
I also think we could condense the rating and the review into 1 record, similar to any other product review we'd write. This new kind of review would have a
review.rating
and areview.comment
(as well as the usual timestamps).In order to migrate the existing data, my first thoughts are:
integer
column on thereviews
table that we'll callrating
screenings
next
if the movie has neitherrating
norreview
next
if the movie has only areview
(but log this somehow, maybe console putsing so we can see the data. we'll probably want to backfill it).rating
and areview
, copy therating
over to thereview.rating
fieldrating
, make a newreview
record, populating it with all of originalrating
datareview
s that are missing arating
review.rating
ratings
tableCode changes:
reviewed_movies
andrated_movies
that will require updating