forked from mtusi2026/mtusi2026lab5
- RabbitMQ quorum queue, persistent messages and publisher confirms - S3 staging plus PostgreSQL attachments/jobs outbox transaction - worker variants (thumbnail, crop, optimized WebP), DB lease and lease sweeper - jittered retry, permanent failures, explicit replay and admission cap - deterministic crash hooks, resilience script and evidence for grade 4 - async-aware custom tests, oversized pixel case, docs and changelog
28 lines
1.1 KiB
SQL
28 lines
1.1 KiB
SQL
DROP TABLE IF EXISTS attachment_jobs;
|
|
|
|
ALTER TABLE attachments DROP CONSTRAINT IF EXISTS attachments_variants_array;
|
|
ALTER TABLE attachments DROP CONSTRAINT IF EXISTS attachments_pipeline_version;
|
|
ALTER TABLE attachments DROP CONSTRAINT IF EXISTS attachments_error_state;
|
|
ALTER TABLE attachments DROP CONSTRAINT IF EXISTS attachments_status;
|
|
|
|
-- Collapse asynchronous states back to lab4's single in-flight state. Ready
|
|
-- and failed rows keep their meaning; queued/processing work is abandoned.
|
|
UPDATE attachments
|
|
SET status = 'pending', error_code = NULL
|
|
WHERE status IN ('queued', 'processing');
|
|
|
|
ALTER TABLE attachments
|
|
DROP COLUMN IF EXISTS variants,
|
|
DROP COLUMN IF EXISTS pipeline_version,
|
|
DROP COLUMN IF EXISTS staging_key,
|
|
DROP COLUMN IF EXISTS ready_at;
|
|
|
|
ALTER TABLE attachments
|
|
ADD CONSTRAINT attachments_status
|
|
CHECK (status IN ('pending', 'ready', 'failed')),
|
|
ADD CONSTRAINT attachments_error_state CHECK (
|
|
(status = 'pending' AND error_code IS NULL) OR
|
|
(status = 'ready' AND error_code IS NULL) OR
|
|
(status = 'failed' AND error_code IS NOT NULL)
|
|
);
|