Share bounty schema column migrations#905
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR refactors the bounties table column migration in ChangesSchema Migration Refactor
Possibly related PRs
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
catcherintheroad-hub
left a comment
There was a problem hiding this comment.
Reviewed current head a89a582b2218e7a00a6ae8ee5fa7afa9850fef4a for the schema-migration helper change.
What I checked:
app/db.pykeeps the existing legacy bounty-column migration behavior while consolidating the repeated add-column path into_add_bounty_column_if_missing().- The helper refreshes
existing_columnsafter a successfulALTER TABLE, so later migration decisions in the same schema pass still see the updated table state. - The
awards_paidbackfill remains scoped to the case where that column was just created, matching the previous migration behavior. - Submission unique-index creation is still separate from the bounty-column migration loop.
tests/test_ledger.pynow covers both migrated bounty columns and the submission unique index on an existing database.
Local validation run:
uv run --python 3.12 --extra dev python -m pytest tests/test_ledger.py::test_create_schema_migrates_existing_bounty_columns_and_submission_index tests/test_migrations.py -q-> 2 passeduv run --python 3.12 --extra dev python -m pytest tests/test_ledger.py tests/test_migrations.py -q-> 23 passeduv run --python 3.12 --extra dev ruff check app/db.py tests/test_ledger.py tests/test_migrations.py-> passeduv run --python 3.12 --extra dev ruff format --check app/db.py tests/test_ledger.py tests/test_migrations.py-> passeduv run --python 3.12 --extra dev mypy app/db.py-> passeduv run --python 3.12 --extra dev python scripts/docs_smoke.py-> passedgit diff --check origin/main...HEADandgit merge-tree --write-tree origin/main HEAD-> clean
Caveat: GitHub currently reports merge state as UNSTABLE because only the CodeRabbit status is visible on the PR from my side, but the PR is mergeable locally and the focused/broader validation above passed.
This looks safe to accept for the cleanup bounty scope.
MolhamHamwi
left a comment
There was a problem hiding this comment.
Reviewed current head a89a5822b926585e28539e084f1f4a16f70b7205 for the #838 review bounty. I checked app/db.py and tests/test_ledger.py, and ran python3 -m pytest tests/test_ledger.py -q locally: 22 passed.
Two concrete observations:
- The new
_add_bounty_column_if_missinghelper updates the in-memorybounty_columnsset after eachALTER TABLE, so the migration loop remains idempotent even if adjacent column entries are refactored or reused later in the same pass. - The
awards_paidbackfill is still gated onaddedfor that column, preserving the old-schema-only behavior and avoiding a repeatedstatus = 'paid'overwrite on databases that already have the column.
The added regression also verifies both newly shared bounty columns and the existing uq_submission_bounty_url index creation path against a legacy table shape. I do not see a blocker in this refactor.
heickerv1001-dev
left a comment
There was a problem hiding this comment.
Bounty #838 / Bounty #798 follow-up on PR #905: the new unique index on submissions (bounty_id, url) can break startup on legacy databases that already contain duplicate rows. I reproduced the failure path with SQLite: duplicate rows cause CREATE UNIQUE INDEX IF NOT EXISTS uq_submission_bounty_url ON submissions (bounty_id, url) to raise UNIQUE constraint failed: submissions.bounty_id, submissions.url. The migration currently assumes clean historical data and does not dedupe or otherwise guard the index creation, so this is a real upgrade-risk regression in app/db.py.
Errordog2
left a comment
There was a problem hiding this comment.
Reviewed the bounty schema column migration sharing change.
Validation performed locally:
.venv\Scripts\python.exe -m pytest tests/test_ledger.py -k "schema or bounty_columns or migration or submission_index"-> 1 passed.venv\Scripts\python.exe -m pytest tests/test_ledger.py-> 22 passed.venv\Scripts\python.exe -m ruff check app/db.py tests/test_ledger.py-> passed.venv\Scripts\python.exe -m ruff format --check app/db.py tests/test_ledger.py-> passed.venv\Scripts\python.exe -m mypy app/db.py-> passedgit diff --check-> passedgit merge-tree $(git merge-base origin/main HEAD) origin/main HEAD-> clean merge
The migration helper keeps each ALTER TABLE idempotent via the tracked column set, preserves the paid-bounty awards backfill only when awards_paid is newly added, and the expanded migration test covers the GitHub paid issue columns plus the submissions uniqueness index. Looks good to me.
Bounty #846
Summary
bountiescolumn migrations increate_schema()awards_paidand the submission unique-index creation behaviorDuplicate check
gh search prs db.py --repo ramimbo/mergework --state open-> no resultsgh search prs migrate_schema --repo ramimbo/mergework --state open-> no resultsgh search prs "schema migration" --repo ramimbo/mergework --state open-> no resultsValidation
.\.venv\Scripts\python.exe -m pytest tests\test_ledger.py::test_create_schema_migrates_existing_bounty_columns_and_submission_index tests\test_migrations.py -q-> 2 passed.\.venv\Scripts\python.exe -m ruff check app\db.py tests\test_ledger.py tests\test_migrations.py-> passed.\.venv\Scripts\python.exe -m ruff format --check app\db.py tests\test_ledger.py tests\test_migrations.py-> 3 files already formatted.\.venv\Scripts\python.exe -m mypy app\db.py-> successgit diff --check-> cleanScope: maintainability-only cleanup in schema migration helper code. No migration target columns, ledger behavior, wallet behavior, treasury behavior, payout behavior, proposal execution, private data, exchange, bridge, cash-out, or MRWK price behavior changed.
Summary by CodeRabbit
Refactor
Tests