diff --git a/src/client/java/teammates/client/scripts/sql/DataMigrationForCourseEntitySql50Newest.java b/src/client/java/teammates/client/scripts/sql/DataMigrationForCourseEntitySql50Newest.java index ebed701e704..f1134bb562c 100644 --- a/src/client/java/teammates/client/scripts/sql/DataMigrationForCourseEntitySql50Newest.java +++ b/src/client/java/teammates/client/scripts/sql/DataMigrationForCourseEntitySql50Newest.java @@ -323,6 +323,13 @@ private void migrateFeedbackQuestion(teammates.storage.sqlentity.FeedbackSession oldResponses = ofy().load().type(FeedbackResponse.class) .filter("feedbackQuestionId", oldQuestion.getId()).list(); } + + if (oldResponses == null || oldResponses.size() == 0) { + log(String.format("No responses found for question %s %s in course %s", oldQuestion.getId(), oldQuestion.getQuestionNumber(), newSession.getCourse().getId())); + return; + } + + for (FeedbackResponse oldResponse : oldResponses) { Section newGiverSection = sectionNameToSectionMap.get(oldResponse.getGiverSection()); Section newRecipientSection = sectionNameToSectionMap.get(oldResponse.getRecipientSection()); @@ -340,6 +347,11 @@ private void migrateFeedbackResponse(teammates.storage.sqlentity.FeedbackQuestio // cascade migrate response comments List oldComments = responseIdToCommentsMap.get(oldResponse.getId()); + if (oldComments == null) { + log(String.format("No comments found for response %s in course %s", oldResponse.getId(), oldResponse.getCourseId())); + return; + } + for (FeedbackResponseComment oldComment : oldComments) { migrateFeedbackResponseComment(newResponse, oldComment, newGiverSection, newRecipientSection); } diff --git a/src/client/java/teammates/client/scripts/sql/DataMigrationForCourseEntitySql50Oldest.java b/src/client/java/teammates/client/scripts/sql/DataMigrationForCourseEntitySql50Oldest.java index 525d754847e..32c5ec0af4b 100644 --- a/src/client/java/teammates/client/scripts/sql/DataMigrationForCourseEntitySql50Oldest.java +++ b/src/client/java/teammates/client/scripts/sql/DataMigrationForCourseEntitySql50Oldest.java @@ -324,6 +324,12 @@ private void migrateFeedbackQuestion(teammates.storage.sqlentity.FeedbackSession .filter("feedbackQuestionId", oldQuestion.getId()).list(); } log(String.format("Feedback question %d has %d responses associated with it", oldQuestion.getQuestionNumber(), oldResponses.size())); + + if (oldResponses == null || oldResponses.size() == 0) { + log(String.format("No responses found for question %s %s in course %s", oldQuestion.getId(), oldQuestion.getQuestionNumber(), newSession.getCourse().getId())); + return; + } + for (FeedbackResponse oldResponse : oldResponses) { Section newGiverSection = sectionNameToSectionMap.get(oldResponse.getGiverSection()); Section newRecipientSection = sectionNameToSectionMap.get(oldResponse.getRecipientSection()); @@ -341,6 +347,11 @@ private void migrateFeedbackResponse(teammates.storage.sqlentity.FeedbackQuestio // cascade migrate response comments List oldComments = responseIdToCommentsMap.get(oldResponse.getId()); + if (oldComments == null) { + log(String.format("No comments found for response %s in course %s", oldResponse.getId(), oldResponse.getCourseId())); + return; + } + for (FeedbackResponseComment oldComment : oldComments) { migrateFeedbackResponseComment(newResponse, oldComment, newGiverSection, newRecipientSection); } diff --git a/src/main/java/teammates/storage/sqlentity/User.java b/src/main/java/teammates/storage/sqlentity/User.java index 7b5b8ed1bc0..7fe8850980f 100644 --- a/src/main/java/teammates/storage/sqlentity/User.java +++ b/src/main/java/teammates/storage/sqlentity/User.java @@ -22,9 +22,7 @@ * Represents a User. */ @Entity -@Table(name = "Users", uniqueConstraints = { - @UniqueConstraint(name = "Unique email and courseId", columnNames = { "email", "courseId" }) -}) +@Table(name = "Users") @Inheritance(strategy = InheritanceType.JOINED) public abstract class User extends BaseEntity { @Id