Columns
| Column | Type | Size | Nulls | Auto | Default | Children | Parents | Comments | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| approval_request_id | uuid | 2147483647 | null |
|
|
|||||||||
| task_id | uuid | 2147483647 | null |
|
|
|||||||||
| company_id | uuid | 2147483647 | null |
|
|
|||||||||
| target_task_version | int8 | 19 | null |
|
|
|||||||||
| target_content_revision | int8 | 19 | null |
|
|
|||||||||
| approved_task_version | int8 | 19 | √ | null |
|
|
||||||||
| target_fingerprint | varchar | 64 | null |
|
|
|||||||||
| status | varchar | 20 | null |
|
|
|||||||||
| ai_snapshot_json | text | 2147483647 | √ | null |
|
|
||||||||
| hr_snapshot_json | text | 2147483647 | null |
|
|
|||||||||
| changed_fields_json | text | 2147483647 | null |
|
|
|||||||||
| source_versions_json | text | 2147483647 | null |
|
|
|||||||||
| requested_by | uuid | 2147483647 | null |
|
|
|||||||||
| requested_at | timestamptz | 35,6 | null |
|
|
|||||||||
| decided_by | uuid | 2147483647 | √ | null |
|
|
||||||||
| decided_at | timestamptz | 35,6 | √ | null |
|
|
||||||||
| decision_reason | varchar | 500 | √ | null |
|
|
||||||||
| invalidated_at | timestamptz | 35,6 | √ | null |
|
|
||||||||
| invalidation_reason | varchar | 500 | √ | null |
|
|
||||||||
| created_at | timestamptz | 35,6 | null |
|
|
|||||||||
| updated_at | timestamptz | 35,6 | null |
|
|
|||||||||
| version | int8 | 19 | 0 |
|
|
Indexes
| Constraint Name | Type | Sort | Column(s) |
|---|---|---|---|
| pk_approval_request | Primary key | Asc | approval_request_id |
| idx_approval_request_task_status | Performance | Asc/Asc/Asc/Asc | company_id + task_id + status + requested_at |
| uq_approval_request_id_task_company | Must be unique | Asc/Asc/Asc | approval_request_id + task_id + company_id |
Check Constraints
| Constraint Name | Constraint |
|---|---|
| ck_approval_request_target_version | (target_task_version >= 0) |
| ck_approval_request_target_revision | (target_content_revision >= 0) |
| ck_approval_request_approved_task_version | (((status)::text <> 'APPROVED'::text) OR (approved_task_version IS NOT NULL)) |
| ck_approval_request_decision | ((((status)::text = 'PENDING'::text) AND (decided_by IS NULL) AND (decided_at IS NULL) AND (approved_task_version IS NULL) AND (invalidated_at IS NULL)) OR (((status)::text = ANY ((ARRAY['APPROVED'::character varying, 'REJECTED'::character varying])::text[])) AND (decided_by IS NOT NULL) AND (decided_at IS NOT NULL) AND (invalidated_at IS NULL)) OR (((status)::text = 'INVALIDATED'::text) AND (invalidated_at IS NOT NULL))) |
| ck_approval_request_source_versions_not_blank | (char_length(TRIM(BOTH FROM source_versions_json)) > 0) |
| ck_approval_request_changed_fields_not_blank | (char_length(TRIM(BOTH FROM changed_fields_json)) > 0) |
| ck_approval_request_version | (version >= 0) |
| ck_approval_request_approved_version | ((approved_task_version IS NULL) OR (approved_task_version >= target_task_version)) |
| ck_approval_request_fingerprint_length | (char_length((target_fingerprint)::text) = 64) |
| ck_approval_request_hr_snapshot_not_blank | (char_length(TRIM(BOTH FROM hr_snapshot_json)) > 0) |
| ck_approval_request_status | ((status)::text = ANY ((ARRAY['PENDING'::character varying, 'APPROVED'::character varying, 'REJECTED'::character varying, 'INVALIDATED'::character varying])::text[])) |
| ck_approval_request_fingerprint_lowercase | ((target_fingerprint)::text = lower((target_fingerprint)::text)) |
| ck_approval_request_updated_at | (updated_at >= created_at) |

