-
Notifications
You must be signed in to change notification settings - Fork 687
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
Apply database migration on backup restore #3737
Conversation
Do the test steps need a |
Backups restored to a newer version of SecureDrop may introduce breakage if a migration has occurred. dpkg-reconfigure will call the postinst which will in turn apply all necessary alembic migrations to the database.
b6a15d4
to
0f2ce05
Compare
Woops, updated the test plan with restore instructions. Thanks @zenmonkeykstop ! |
Codecov Report
@@ Coverage Diff @@
## develop #3737 +/- ##
========================================
Coverage 84.76% 84.76%
========================================
Files 44 44
Lines 2757 2757
Branches 297 297
========================================
Hits 2337 2337
Misses 353 353
Partials 67 67 Continue to review full report at Codecov.
|
@@ -45,6 +45,8 @@ def main(): | |||
# If the process exits with a non-zero return code, raises an exception. | |||
subprocess.check_call(['service', 'apache2', 'restart']) | |||
subprocess.check_call(['service', 'tor', 'reload']) | |||
# Apply database migrations (if backed-up version < version to restore) |
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.
Technically this comment is wrong. It will always attempt to migrate to head
which will throw an exception if we restore a v3 version DB to a Debian package with v2 migration code (meaning one migration is missing) alembic
will explode and yell at us that it can't do the thing.
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.
followed test plan, all is as expected after restore ✅
Status
Ready for review
Description of Changes
Fixes #3732 .
Apply migrations as part of backup restore script.
Testing
./securedrop-admin backup
install_files/ansible-base/
./securedrop-admin restore <filename>
sqlite3 /var/lib/securedrop/db.sqlite
):a. replies
b. submissions
c. sources
d. journalists
Deployment
This will be used when restoring from backup. Code will be updated via SecureDrop Updater GUI.
Checklist
If you made changes to
securedrop-admin
:make -C admin test
) pass in the admin development containerIf you made non-trivial code changes: