-
Notifications
You must be signed in to change notification settings - Fork 3
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
User re-create with get_or_create #150
Comments
If we don't create users when migrating data from mongodb, it will result in data loss as thread/comment needs an author as of now to be created. Would we want that behaviour via a switch? |
may be we can rely on ForumUser instead of creating User obj and it's relation with ForumUser. |
@Faraz32123 the ForumUser model also has a required OneToOne mapping with the user model so even if we use that, we would still require the corresponding User object to be linked with ForumUser first based on the current implementation. |
It might be an edge case but in a real-world scenario, there would be no data in cs_comment for the user that does not exist and vice versa, if there is such inconsistency we should not create a new user for just adding forum data, and that data should be skipped, but we should log that data for future reference. |
One way around would be that we can separate get and create, incase of get let the current code flow run, but while creating user, may be we can mark user as inactive or something or create a single anonymous user for all these kinds of posts/data, so that we don't loose older useful comments/data from the users that were deleted in the LMS and their data exists in mongodb. |
@AhtishamShahid I believe that the scenario is that some users have authored threads and comments and are present in mongodb. However, they have deleted their accounts in the edx platform but their data remains in the mongodb. That user data along with their activity is being pulled from mongo to mysql once we run the migration command. Hence, we have to make a strategic decision if we want to lose that data, recover that data, or as @Faraz32123 mentioned assign an anonymous user to those threads and comments. |
@regisb @jristau1984 what do you guys suggest? |
We don't have enough data about how many records exist that have no users for now
It would be great if we have some data before making any decision, can you create a simple script to get count of posts and comments without users? |
Management command is using
get_or_create
to fetch user which will create user when it does not exist. If a user does not exist, we don’t need to migrate their data. This could lead to issues i.e. deleted accounts are unintentionally recreated. Ideally, we should control this behavior using a switch in management command. This will ensure users are only created when explicitly needed. If we skip adding switch, there’s a risk of unnecessary account creation and data migration for non-existent users.Code
The text was updated successfully, but these errors were encountered: