Migration backup#6742
Open
semohr wants to merge 5 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
PR add safety net for db schema migrations: make timestamp .bak copy of library db before first pending migration run. This fit beets startup migration path, so user can roll back when migration go bad.
Changes:
- Add
create_backup_before_migrationsconfig (defaultyes) and document it. - Add backup creation hook in
Migration.migrate_modelbefore migration work runs. - Add test for config on/off behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
beets/dbcore/db.py |
Add backup-before-migration hook and Database.create_copy helper. |
beets/config_default.yaml |
Set default create_backup_before_migrations: yes. |
docs/reference/config.rst |
Document new global config option. |
docs/changelog.rst |
Add changelog entry for migration backup feature. |
test/library/test_migrations.py |
Add regression test for backup creation controlled by config. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6742 +/- ##
==========================================
+ Coverage 74.52% 74.55% +0.02%
==========================================
Files 162 162
Lines 20818 20836 +18
Branches 3295 3297 +2
==========================================
+ Hits 15515 15534 +19
Misses 4547 4547
+ Partials 756 755 -1
🚀 New features to boost your workflow:
|
snejus
requested changes
Jun 16, 2026
| assert str_item.path == abs_bytes_path | ||
|
|
||
|
|
||
| class TestMigrationBackup: |
Member
There was a problem hiding this comment.
Would it be possible to move this test to any of existing test classes? Ideally we'd want to reuse the setup
3 tasks
94e30ac to
f9080b2
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Creates a timestamped
.bakcopy of the database before any pending schema migration runs, so users can recover if a migration goes wrong. Controlled by the newcreate_backup_before_migrationsconfig option (default:yes).Changes:
Migration.migrate_model: before running migration data, copies the database file to<library.db>.<timestamp>.bak(once per startup, guarded by aClassVarflag)Database.create_copy(dest): copies the SQLite file to the given pathTODOs:
docs/changelog.rstto the bottom of one of the lists near the top of the document.)