Skip to content
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

Add data migration to purge deleted submissions #744

Merged
merged 1 commit into from
Jun 30, 2021

Conversation

jnm
Copy link
Member

@jnm jnm commented Jun 30, 2021

Removes Instances in PostgreSQL where deleted_at is non-null and corresponding documents in MongoDB (whose _deleted_at attribute is non-null).

Description

Automatically removes submissions that were already marked as deleted. Necessary for self-hosters so that the changes in #732 do not cause deleted submissions to resurface.
⚠️ Includes a migration that could be slow on large databases. If you run your own instance of KoBoToolbox with many thousands of submissions, consider using manage.py shell_plus inside the KoBoCAT container (kobo-install/run.py -cf exec kobocat bash) to purge deleted submissions using the code shown in #696 prior to upgrading to this release.

Related issues

Closes #733

WARNING: may be slow on large databases. Mention this in release notes.
Closes #733.
Comment on lines +18 to +20
print(
f'Purging {to_purge.count()} deleted instances...', end='', flush=True
)
Copy link
Contributor

@noliveleger noliveleger Jun 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: I cannot see the output of these print .
In other migrations, we used sys.stdout.write and sys.stderr.write

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I'm only now seeing this! I'm surprised you couldn't see it the output if count was greater than zero on your database, but print() certainly doesn't seem ideal to use here (although neither does sys.stdout.write 😉). I guess migrations are part of a management command and theoretically ought to have access somehow to self.stdout provided somewhere by the BaseCommand class.

Be more insistent that I acknowledge your feedback next time 😛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data migration to purge instances with deleted_at set
2 participants