kgz.me - Klaus Zanders

Thoughts of a random guy on the internet. Doing things with software ... or video

PostgreSQL - enforce only one column filled via constraint

2023-08-08 2 min read code-snippets
Recently I got a task, that required me to ensure that of two columns, either none, or only one get filled. That should be ensured on the database level. In my #ruby code it would be easy to add a validation to check for this, but as we are doing manual inserts into the DB, we need to also make sure, that the database enforces this constraint. Luckily, postgres has a feature for us, that was introduced in version 9. Continue reading

Welcome Again

2019-10-04 1 min read
This is another try on a reboot of this blog … Let’s see if this is works this time ;) Enjoy, Klaus