Add the jobs, outbox and variants schema as an additive migration

Migration 0004 widens the attachment states to queued, processing and
failed, adds the staging and original keys, the published pipeline
version and the error code, and moves the lab 4 object key into them
while leaving the old column nullable until a contract step. New tables
hold the variants under the effect key (attachment, pipeline version,
name), the jobs with attempt, claims and lease, the outbox rows the
relay publishes and the audit of job transitions. Partial indexes serve
the relay scan of unpublished rows, the search for expired leases and
the staging cleanup.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Artyom
2026-10-29 00:43:34 +03:00
co-authored by Claude Opus 5.5
parent d9bcc7324b
commit 64fdaa03f2
3 changed files with 160 additions and 4 deletions
@@ -1,7 +1,7 @@
## 1. Схема
- [ ] 1.1 Миграция `0004_jobs.sql`: статусы `queued/processing/failed`, `staging_key`, `original_key`, `published_version`, `error_code` у `attachments` (перенос `object_key` лабы 4), таблицы `attachment_variants`, `jobs`, `outbox`, `job_events`, частичные индексы `outbox_pending_idx`, `jobs_lease_idx`, `attachments_staged_idx`
- [ ] 1.2 Проверка группы: тест миграций — версия `0004`, повтор без изменений, колонки из `.prep/lab5/tools/schema.reference.sql` на месте, дубль ключа эффекта отклоняется первичным ключом
- [x] 1.1 Миграция `0004_jobs.sql`: статусы `queued/processing/failed`, `staging_key`, `original_key`, `published_version`, `error_code` у `attachments` (перенос `object_key` лабы 4), таблицы `attachment_variants`, `jobs`, `outbox`, `job_events`, частичные индексы `outbox_pending_idx`, `jobs_lease_idx`, `attachments_staged_idx`
- [x] 1.2 Проверка группы: тест миграций — версия `0004`, повтор без изменений, колонки из `.prep/lab5/tools/schema.reference.sql` на месте, дубль ключа эффекта отклоняется первичным ключом
## 2. Зона `attachments`: домен и приложение