Phuks-co / throat

Open Source link aggregator and discussion platform powering Phuks
https://phuks.co
MIT License
74 stars 32 forks source link

Enforce in-practice not null constraints at the model & DB layer #367

Closed robjwells closed 3 years ago

robjwells commented 3 years ago

This PR changes some fields on Sub and SubPost to disallow null, in cases where if the field is actually null (None) it violates assumptions elsewhere in the application and causes an exception to be thrown.

It includes a schema-only migration for the sub and sub_post tables to add these constraints. The failures are generally very obvious, so I think it’s probably unlikely that nulls exist in these columns in the wild. In any case, it’s not necessarily obvious what the right data migration would be in each case.

The commit message for 27fcca2 contains more information about the circumstances where having a null in a field causes a problem.

Thanks to @happy-river for their feedback in #366, from which this PR was extracted.