-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: remove links between question instances and (detail) responses #4141
Conversation
Test summaryRun details
Flakiness
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Cloud |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with the change and makes the schema cleaner and data consistent. However, to be discussed whether we want to delete element instances and thus trigger cascading delete (or whether we remove cascading delete and actually want to have a transaction fail when an instance is deleted but responses are still around?), or whether we keep element instances around even if the element they correspond to is deleted (or even also for quizzes that were published but are deleted?), thus keeping leaderboards and responses consistent (as the instance should contain all data necessary to know what it was about)? Especially if we want to do timelines, audit logs, and such things, we want to make sure that they cannot change after participants have seen them, and responses should be consistent with such derived data (meaning responses should basically never be deleted).
WalkthroughThis migration overhaul enhances the database schema by removing the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant App
participant Database
User->>App: Submit Question Response
App->>Database: Save Response with Element Instance
Database-->>App: Confirmation
App-->>User: Response Saved
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- packages/prisma/src/prisma/migrations/20240715083055_drop_question_instance_response_links/migration.sql (1 hunks)
- packages/prisma/src/prisma/schema.prisma (3 hunks)
Additional comments not posted (11)
packages/prisma/src/prisma/migrations/20240715083055_drop_question_instance_response_links/migration.sql (9)
10-11
: Approved: Dropping foreign key constraint.Dropping the foreign key constraint
QuestionResponse_elementInstanceId_fkey
is necessary for modifying theelementInstanceId
column.
13-14
: Approved: Dropping foreign key constraint.Dropping the foreign key constraint
QuestionResponse_questionInstanceId_fkey
is necessary as thequestionInstanceId
column is being removed.
16-17
: Approved: Dropping foreign key constraint.Dropping the foreign key constraint
QuestionResponseDetail_elementInstanceId_fkey
is necessary for modifying theelementInstanceId
column.
19-20
: Approved: Dropping foreign key constraint.Dropping the foreign key constraint
QuestionResponseDetail_questionInstanceId_fkey
is necessary as thequestionInstanceId
column is being removed.
22-23
: Approved: Dropping index.Dropping the index
QuestionResponse_participantId_questionInstanceId_key
is necessary as thequestionInstanceId
column is being removed.
33-34
: Approved: Adding foreign key constraint.Adding the foreign key constraint
QuestionResponse_elementInstanceId_fkey
ensures referential integrity with theElementInstance
table.
36-37
: Approved: Adding foreign key constraint.Adding the foreign key constraint
QuestionResponseDetail_elementInstanceId_fkey
ensures referential integrity with theElementInstance
table.
29-31
: Approved: AlteringQuestionResponseDetail
table.Dropping the
questionInstanceId
column and setting theelementInstanceId
column to NOT NULL is necessary for the schema changes.Ensure that there are no existing NULL values in the
elementInstanceId
column before applying this change.
25-27
: Approved: AlteringQuestionResponse
table.Dropping the
questionInstanceId
column and setting theelementInstanceId
column to NOT NULL is necessary for the schema changes.Ensure that there are no existing NULL values in the
elementInstanceId
column before applying this change.packages/prisma/src/prisma/schema.prisma (2)
1015-1016
: Approved: Changes toQuestionResponse
model.The removal of the
questionInstanceId
field and making theelementInstance
relationship mandatory with ON DELETE and ON UPDATE CASCADE is correctly reflected.
1042-1043
: Approved: Changes toQuestionResponseDetail
model.The removal of the
questionInstanceId
field and making theelementInstance
relationship mandatory with ON DELETE and ON UPDATE CASCADE is correctly reflected.
Test summaryRun details
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Cloud |
This pull request makes the following changes to the database scheme (incl. migration):
QuestionInstance
(only used in live quiz) andQuestionResponse
andQuestionResponseDetails
- all corresponding ids are set to null alreadyQuestionResponse
/QuestionResponseDetail
andElementInstance
required, since response objects without this link cannot be associated with a question / flashcard / ... anyway and are therefore not really informative - all of the corresponding ids are defined (not response withnull
aselementInstanceId
)ElementInstance
, since there might be responses without an assigned question otherwise, which does not make sense, since the results cannot be interpreted without the question.Summary by CodeRabbit
New Features
elementInstanceId
a required field in theQuestionResponse
andQuestionResponseDetail
tables.Bug Fixes
questionInstanceId
field from theQuestionResponse
andQuestionResponseDetail
models to streamline relationships.Refactor
ElementInstance
, enhancing the overall structure of the data model.