nyaruka / rapidpro

RapidPro is a cloud based SaaS allowing organizations to visually build scalable interactive messaging applications.
Other
36 stars 24 forks source link

Add db constraint to ensure contact status is valid #5368

Closed rowanseymour closed 1 month ago

rowanseymour commented 1 month ago

We have a db trigger on status to put contacts in status groups.. but it doesn't complain if you set empty or nonsense. We're gonna let contact creates and imports set status so wanna be completely sure we're not letting junk status values thru.

ALTER TABLE "contacts_contact" ADD CONSTRAINT "contact_status_valid" 
CHECK ("status" IN ('A', 'B', 'S', 'V')) NOT VALID;
ALTER TABLE "contacts_contact" VALIDATE CONSTRAINT "contact_status_valid";
codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (21bb06b) to head (f76d1a1). Report is 6 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #5368 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 492 493 +1 Lines 25047 25053 +6 ========================================= + Hits 25047 25053 +6 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.