fix: harden attachment cleanup

This commit is contained in:
2026-10-09 13:27:58 +03:00
parent f8c31de7c0
commit 3fde1c324c
8 changed files with 134 additions and 24 deletions
@@ -0,0 +1,9 @@
ALTER TABLE attachments
DROP CONSTRAINT attachments_ready_at;
ALTER TABLE attachments
ADD CONSTRAINT attachments_ready_at CHECK (
(status = 'pending' AND ready_at IS NULL) OR
(status = 'ready' AND ready_at IS NOT NULL) OR
status = 'deleting'
);