-- lab5: constraint attachments_error_code должен знать про queued/processing. -- Идемпотентно: DROP IF EXISTS — можно применять повторно. ALTER TABLE attachments DROP CONSTRAINT IF EXISTS attachments_error_code; ALTER TABLE attachments ADD CONSTRAINT attachments_error_code CHECK ( (status = 'failed') = (error_code IS NOT NULL) );