-
Notifications
You must be signed in to change notification settings - Fork 37
Add migration to set DB constraint #1305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fewer-poll-stats-rows-2
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a database migration that introduces a check constraint to ensure only one segment field can be set at a time in the stats_pollstats table. The constraint validates that at most one of the four segment fields (age_segment_id, gender_segment_id, location_id, scheme_segment_id) contains a non-null value.
- Adds a PostgreSQL check constraint using
num_nonnulls()function - Includes a reverse migration to properly drop the constraint
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
|
|
||
| # language=SQL | ||
| CONTRAINT_SQL_POLLSTATS_ONE_SEGMENT_SET_MAX = """ |
Copilot
AI
Nov 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'CONTRAINT' to 'CONSTRAINT'.
| """ | ||
|
|
||
| # language=SQL | ||
| CONTRAINT_SQL_POLLSTATS_ONE_SEGMENT_SET_MAX_DROP = """ |
Copilot
AI
Nov 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'CONTRAINT' to 'CONSTRAINT'.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## fewer-poll-stats-rows-2 #1305 +/- ##
========================================================
Coverage 83.94% 83.94%
========================================================
Files 48 48
Lines 5899 5899
========================================================
Hits 4952 4952
Misses 947 947 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a809aad to
4277edf
Compare
No description provided.