checking for isdeleted everywhere is not an issue, you have to check for userid anyway (if the database contains data from multiple users). You can enforce the check by code, by placing those two checks on a separate function (or use views)
create table mytable (
id serial primary key,
my_column varchar not null,
my_column_repetitions integer not null default 0,
deleted_at datetime,
unique (my_column, my_column_repetitions),
check (deleted_at is not null and my_column_repetitions > 0 or deleted_at is null and my_column_repetitions = 0)
)
并应用这个逻辑: 当一行是当前的,即没有删除,my_column_repetitions应该保持默认值 0,当该行是软删除它的 my_column_repetitions需要更新到 (max. number of repetitions on soft-deleted rows) + 1.