Postgresql – How to avoid code duplication on a condition that repeats in many different queries
Several (20+) tables in my database define columns current_since::timestamptz and current_until::timestamptz. Each row in each of those tables follows the same rules: If current_since is null, the row is considered "draft". If current_sice is not null and current_until is null,…