allocation

-1 rows


Columns

Column Type Size Nulls Auto Default Children Parents Comments
id uuid 2147483647 null
prison_code varchar 6 null
prison_migration_date_history.prison_code Implied Constraint R
staff_id int8 19 null
person_identifier varchar 10 null
allocated_at timestamp 29,6 null
allocation_type bpchar 1 null
allocated_by varchar 64 null
allocation_reason_id int8 19 null
reference_data.id allocation_allocation_reason_id_fkey R
deallocated_at timestamp 29,6 null
deallocation_reason_id int8 19 null
reference_data.id allocation_deallocation_reason_id_fkey R
deallocated_by varchar 64 null
is_active bool 1 null
policy_code varchar 16 null
policy.code allocation_policy_code_fkey R

Indexes

Constraint Name Type Sort Column(s)
pk_allocation Primary key Asc id
idx_active_staff_allocations Performance Asc/Asc/Asc staff_id + prison_code + policy_code
idx_allocation_people_at Performance Asc/Asc/Asc/Asc staff_id + person_identifier + allocated_at + policy_code
idx_allocation_person_identifier Performance Asc/Asc person_identifier + policy_code
idx_allocation_prison_code Performance Asc/Asc prison_code + policy_code
uq_allocation Must be unique Asc/Asc person_identifier + policy_code

Check Constraints

Constraint Name Constraint
ch_allocation_is_not_active ((NOT ((is_active = false) AND ((deallocated_at IS NULL) OR (deallocated_by IS NULL) OR (deallocation_reason_id IS NULL)))))
ch_allocation_is_active ((NOT ((is_active = true) AND ((deallocated_at IS NOT NULL) OR (deallocated_by IS NOT NULL) OR (deallocation_reason_id IS NOT NULL)))))
allocation_allocation_type ((allocation_type = ANY (ARRAY['A'::bpchar, 'M'::bpchar, 'P'::bpchar])))

Relationships