refactor: migrate patch test schema from service-level to dedicated tables

- Remove patch_test_duration_hours from services table
- Add new patch_tests table with service_ids array, notice_duration_hours, expiry_months
- Add new user_patch_tests table linking users to patch_tests with tested_at
- Update services handler to check patch_tests.service_ids for eligibility
- Update booking creation to validate patch test requirements (24h notice, 6mo expiry)
- Update booking completion to extend patch test validity (reset tested_at)
- Update admin handlers for new patch test CRUD operations
- Update test fixtures and test cases for new schema
- Update seeding script to create patch_tests and link to gel services
This commit is contained in:
2026-02-24 22:17:50 +00:00
parent f59595eeec
commit c6fe9e92a7
5 changed files with 173 additions and 443 deletions
+7
View File
@@ -155,6 +155,13 @@ CREATE INDEX idx_verification_codes_expires ON verification_codes (expires_at) W
-- =======================================
CREATE TABLE patch_tests (
id CHAR(12) PRIMARY KEY DEFAULT generate_service_id(),
name VARCHAR(100) NOT NULL,
description TEXT,
notice_duration_hours INT NOT NULL DEFAULT 24,
expiry_months INT NOT NULL DEFAULT 6,
service_ids CHAR(12)[] DEFAULT '{}'
);
id CHAR(12) PRIMARY KEY DEFAULT generate_service_id(),
name VARCHAR(100) NOT NULL,
description TEXT,