coryd.dev/queries/triggers/update_days_read.psql

5 lines
240 B
Text

CREATE TRIGGER trigger_update_days_read
AFTER UPDATE OF progress ON books
FOR EACH ROW
WHEN (OLD.progress IS DISTINCT FROM NEW.progress AND (NEW.read_status = 'started' OR NEW.read_status = 'finished'))
EXECUTE FUNCTION update_days_read();