fix: make alembic task model same in staging as in dev and prod - #518
fix: make alembic task model same in staging as in dev and prod#518tombrooks248 wants to merge 1 commit into
Conversation
|
Warning Review limit reached
More reviews will be available in 12 minutes and 38 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughA new Alembic migration ( ChangesTask Table Schema Reconciliation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@migrations/versions/08139a9624a2_reconcile_task_table_details_jsonb_cols_.py`:
- Around line 41-45: The upgrade function creates four indexes with names
"idx_task_dataset", "idx_task_organisation", "idx_task_severity", and
"idx_task_responsibility" on the task table, but the downgrade function does not
remove them. Add a corresponding loop in the downgrade section that drops each
of these four indexes by executing DROP INDEX IF NOT EXISTS statements for each
index name, mirroring the structure of the upgrade block but using DROP INDEX
instead of CREATE INDEX to fully reverse the migration changes.
- Around line 32-36: The current postgresql_using clause in the op.alter_column
call for the "task" table's "details" column only handles exact empty strings
with NULLIF(details, '')::jsonb, but will crash on malformed or whitespace-only
JSON values with InvalidTextRepresentation error. Modify the postgresql_using
parameter to use a safer casting approach that handles invalid JSON gracefully -
consider using a CASE statement or a PostgreSQL function that attempts the JSONB
cast and returns NULL for any malformed values instead of raising an error. This
ensures the migration can run successfully on databases with legacy malformed
data without requiring manual cleanup beforehand.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9ef98fda-0d4d-46fe-9130-35343582eb8b
📒 Files selected for processing (1)
migrations/versions/08139a9624a2_reconcile_task_table_details_jsonb_cols_.py
95284e5 to
7183db1
Compare
7183db1 to
f275403
Compare
What type of PR is this? (check all applicable)
Description
In the previous migration (a41b142924f7) I edited it in place after it had already
been applied to staging — its
detailscolumn was changed from Text to JSONB(plus NOT NULL constraints and indexes) under the same revision id.
Because Alembic only tracks the revision id, not the file contents, staging never re-ran
it and kept the old Text schema, which made /task.json fail with "details value
is not a valid dict".
This migration is a fresh revision that re-applies those
changes so every environment converges on the correct schema.
Related Tickets & Documents
QA Instructions, Screenshots, Recordings
I have done some checks locally that the formatting is all correct but now need to run in staging and then DEV to be sure its ready to merge.
Added/updated tests?
We encourage you to keep the code coverage percentage at 80% and above. Please refer to the Digital Land Testing Guidance for more information.
have not been included
[optional] Are there any post deployment tasks we need to perform?
[optional] Are there any dependencies on other PRs or Work?
Summary by CodeRabbit