fix: make seed_db idempotent and require explicit --reset to drop tables (#1856) - #1893
Open
ionfwsrijan wants to merge 1 commit into
Open
fix: make seed_db idempotent and require explicit --reset to drop tables (#1856)#1893ionfwsrijan wants to merge 1 commit into
ionfwsrijan wants to merge 1 commit into
Conversation
|
@ionfwsrijan is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Problem
src/seed_db.pystarts with an unconditionaldb.drop_all(), wiping every table — users, saved progress, game progress and admin flags — every time the documented seeding script is run on an existing database. It also inserts without the project validation that the data loader relies on.Fix
src/seed_db.py: replacedb.drop_all()with an idempotent upsert —db.create_all()then update-or-insert each project by id (matching the app.py auto-seed behavior) — so running the seed script no longer destroys user data.--resetflag with a confirmation prompt.validate_projects()before any writes, and the whole upsert is committed in one transaction.tests/test_basic.py: addtest_seed_database_is_idempotent_and_preserves_usersverifying a user survives re-seeding and the project count stays correct.Files changed
src/seed_db.pytests/test_basic.pyTesting
py -m pytest tests/ -q→ 522 passed, 19 pre-existing unrelated failures (identical to baseline), 3 skipped.Closes #1856