Лабораторная 4 - Костылев - БПИ2303 - На 5 #132
@@ -1,7 +1,7 @@
|
|||||||
## 1. Схема и миграции
|
## 1. Схема и миграции
|
||||||
|
|
||||||
- [ ] 1.1 `0004_attachment_quarantine.sql`: `quarantine_reason` с `CHECK`, `quarantined_at`, согласованность пары
|
- [x] 1.1 `0004_attachment_quarantine.sql`: `quarantine_reason` с `CHECK`, `quarantined_at`, согласованность пары
|
||||||
- [ ] 1.2 Проверка группы: `make student-test` (`test_migrations.py`: повтор без изменений)
|
- [x] 1.2 Проверка группы: `make student-test` (`test_migrations.py`: повтор без изменений)
|
||||||
|
|
||||||
## 2. Зона `attachments`: домен и приложение
|
## 2. Зона `attachments`: домен и приложение
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
ALTER TABLE attachments
|
||||||
|
ADD COLUMN quarantine_reason text
|
||||||
|
CHECK (quarantine_reason IN ('missing', 'size_mismatch', 'sha_mismatch')),
|
||||||
|
ADD COLUMN quarantined_at timestamptz,
|
||||||
|
ADD CONSTRAINT attachments_quarantine_check
|
||||||
|
CHECK ((quarantine_reason IS NULL) = (quarantined_at IS NULL));
|
||||||
@@ -25,7 +25,12 @@ async def counts() -> list[int]:
|
|||||||
async def test_migrations_are_ordered_and_versioned() -> None:
|
async def test_migrations_are_ordered_and_versioned() -> None:
|
||||||
versions = [version for version, _ in migrations()]
|
versions = [version for version, _ in migrations()]
|
||||||
assert versions == sorted(versions)
|
assert versions == sorted(versions)
|
||||||
assert versions[:3] == ["0001_init", "0002_idempotency_keys", "0003_attachments"]
|
assert versions == [
|
||||||
|
"0001_init",
|
||||||
|
"0002_idempotency_keys",
|
||||||
|
"0003_attachments",
|
||||||
|
"0004_attachment_quarantine",
|
||||||
|
]
|
||||||
applied = await scalar("SELECT array_agg(version ORDER BY version) FROM schema_migrations")
|
applied = await scalar("SELECT array_agg(version ORDER BY version) FROM schema_migrations")
|
||||||
assert applied == versions
|
assert applied == versions
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user