Open
Conversation
This reverts commit 7e7bea7.
create versions for non-voting question types only
6 tasks
Member
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces backend support for versioning and history of answers, which is a significant feature. The implementation adds a new versions table, along with the necessary schema, controller, and routes. The changes are generally well-structured, but there are several critical issues related to error handling and control flow that could lead to crashes. Specifically, several functions don't handle potential {:error, ...} tuples from find_team, leading to MatchError exceptions. There are also opportunities to reduce code duplication and improve adherence to Elixir conventions. I've provided specific comments and suggestions to address these points.
RichDom2185
requested changes
Mar 25, 2026
Updated migration to use up and down instead of change Changed name of 'version' field in versions table to 'content'
missing repo.insert after earlier rebase
This reverts commit cb11670. Identifying source of test errors.
This reverts commit fde5d58. Identifying source of test errors.
This reverts commit 91da5d2. Identifying source of testing errors.
This reverts commit ba88128. Identifying source of test errors.
This reverts commit c8942a8. Identifying source of test errors.
repo insert previously removed during formatting
repo insert previously removed during formatting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements the backend support for the "Versioning and History feature". It adds a "versions" table which tracks history for entries in the "answers" table, and implements the required version schema, controller, and routes.
This change is non-breaking and should be merged before source-academy/frontend#3659.
Database Changes
This PR adds a "versions" table with the following columns:
Each entry in the table represents a version of an answer (from the answer table). There can be multiple versions for one answer.
The migration for this table has been added here: \priv\repo\migrations\20260219073155_create_versions.exs. To update the database to the latest version, run:
Database Design Decisions
Currently, each answer is indexed by a unique submission id + question id combination, which most methods and routes use. Multiple versions of the same answer would have the same submission id + question id combination, and storing them in the current answers table would introduce a lot of breaking changes, so we decided to store them in a separate versions table.
We also decided to store both the answer content in both the answer and versions table. Each version entry references an entry in the answers table (which cannot be null). Replacing the "answer" field in the answers table with some reference to the versions table (which also cannot be null) makes it difficult to create new answers, and requires an extra join every time an answer is searched for.
Routes
Additional Notes
Related Issues / PRs