fix(migrations): add migration lock and batch DB updates#484
Merged
ReenigneArcher merged 2 commits intomasterfrom Feb 15, 2026
Merged
fix(migrations): add migration lock and batch DB updates#484ReenigneArcher merged 2 commits intomasterfrom
ReenigneArcher merged 2 commits intomasterfrom
Conversation
Introduce a global MIGRATION_LOCK to prevent concurrent migrations and refactor Reddit/Mee6 import flows into internal methods. Migrations now disable database.GIT_ENABLED and restore its original state on completion or error. Reddit migration applies updates in a single transactional context by building an existing-users map and performing inserts/updates with progress logging. Mee6 migration collects updates asynchronously and applies them in batched transactions, with improved error handling and final DB sync.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #484 +/- ##
==========================================
+ Coverage 59.45% 59.96% +0.51%
==========================================
Files 24 24
Lines 1761 1806 +45
==========================================
+ Hits 1047 1083 +36
- Misses 714 723 +9
|
Extract reusable helpers and simplify migration flows for Reddit and Mee6 imports. Added _process_reddit_item and _update_reddit_rank_database to centralize author handling, XP aggregation, DB upsert logic and progress logging; this reduces duplication and improves error handling. For Mee6, added _fetch_mee6_page (with timeout/error handling) and _process_mee6_batch, and changed the migration to fetch pages and apply updates in batches, reducing DB churn. Also updated final stats to use derived counts and restored original Git state before final sync. Overall aims: clearer structure, fewer nested try/except blocks, better logging, and more efficient DB writes.
|
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
Introduce a global MIGRATION_LOCK to prevent concurrent migrations and refactor Reddit/Mee6 import flows into internal methods. Migrations now disable database.GIT_ENABLED and restore its original state on completion or error. Reddit migration applies updates in a single transactional context by building an existing-users map and performing inserts/updates with progress logging. Mee6 migration collects updates asynchronously and applies them in batched transactions, with improved error handling and final DB sync.
Screenshot
Issues Fixed or Closed
Roadmap Issues
Type of Change
Checklist
AI Usage