Last active
November 2, 2015 23:18
-
-
Save efischer19/d62f8ee42b7fbfbc6c9a to your computer and use it in GitHub Desktop.
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
Initial state, release as it currently runs. 2 cohorts have been enabled, and one user is in both of them simultaneously. | |
Database queries at that time | |
mysql> select * from course_groups_cohortmembership; | |
ERROR 1146 (42S02): Table 'edxapp.course_groups_cohortmembership' doesn't exist | |
mysql> select * from course_groups_courseusergroup_users; | |
+----+--------------------+---------+ | |
| id | courseusergroup_id | user_id | | |
+----+--------------------+---------+ | |
| 3 | 1 | 1 | | |
| 4 | 1 | 3 | | |
| 2 | 2 | 3 | | |
| 1 | 2 | 4 | | |
+----+--------------------+---------+ | |
4 rows in set (0.00 sec) | |
Now, we want to apply Eric's awesome new uniqueness constraints, so we begin by applying migrations 0005 and 0006. | |
Here's the same queries after that: | |
mysql> select * from course_groups_courseusergroup_users; | |
+----+--------------------+---------+ | |
| id | courseusergroup_id | user_id | | |
+----+--------------------+---------+ | |
| 3 | 1 | 1 | | |
| 4 | 1 | 3 | | |
| 1 | 2 | 4 | | |
+----+--------------------+---------+ | |
3 rows in set (0.00 sec) | |
mysql> select * from course_groups_cohortmembership; | |
+----+----------------------+---------+---------------------------------+ | |
| id | course_user_group_id | user_id | course_id | | |
+----+----------------------+---------+---------------------------------+ | |
| 1 | 1 | 1 | course-v1:edX+DemoX+Demo_Course | | |
| 2 | 1 | 3 | course-v1:edX+DemoX+Demo_Course | | |
| 3 | 2 | 4 | course-v1:edX+DemoX+Demo_Course | | |
+----+----------------------+---------+---------------------------------+ | |
3 rows in set (0.00 sec) | |
Hooray! user_id 3 was fixed! | |
But not so fast - the code changes aren't yet live, so we aren't enforcing the use of the CohortMembership table at all. | |
Now, the instructor moves all 3 users to a new cohort. Database shows: | |
mysql> select * from course_groups_courseusergroup_users; | |
+----+--------------------+---------+ | |
| id | courseusergroup_id | user_id | | |
+----+--------------------+---------+ | |
| 7 | 3 | 1 | | |
| 6 | 3 | 3 | | |
| 5 | 3 | 4 | | |
+----+--------------------+---------+ | |
3 rows in set (0.00 sec) | |
mysql> select * from course_groups_cohortmembership; | |
+----+----------------------+---------+---------------------------------+ | |
| id | course_user_group_id | user_id | course_id | | |
+----+----------------------+---------+---------------------------------+ | |
| 1 | 1 | 1 | course-v1:edX+DemoX+Demo_Course | | |
| 2 | 1 | 3 | course-v1:edX+DemoX+Demo_Course | | |
| 3 | 2 | 4 | course-v1:edX+DemoX+Demo_Course | | |
+----+----------------------+---------+---------------------------------+ | |
3 rows in set (0.00 sec) | |
So now the tables don't agree, and there's no easy way to fix them. | |
Update 11-02: this is the point at which we'd run the new post_cohort_membership_fix command to fix the database. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment