Constraints

86 Foreign Key Constraints

Constraint Name Child Column Parent Column Delete Rule
fk_ai_candidate_decision_batch_actor_company
ai_candidate_decision_batch.decided_by
ai_candidate_decision_batch.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_ai_candidate_decision_batch_case_company
ai_candidate_decision_batch.case_id
ai_candidate_decision_batch.company_id
workflow_case.case_id
workflow_case.company_id
Restrict delete
fk_ai_candidate_decision_batch_run_company
ai_candidate_decision_batch.ai_run_id
ai_candidate_decision_batch.company_id
ai_run.ai_run_id
ai_run.company_id
Cascade on delete
fk_worker_import_row_worker_company
worker_import_row.worker_id
worker_import_row.company_id
worker.worker_id
worker.company_id
Restrict delete
fk_worker_import_row_job_company
worker_import_row.import_id
worker_import_row.company_id
worker_import_job.import_id
worker_import_job.company_id
Cascade on delete
fk_task_transition_task_company
task_transition_history.task_id
task_transition_history.company_id
task.task_id
task.company_id
Restrict delete
fk_task_transition_actor_company
task_transition_history.actor_id
task_transition_history.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_audit_event_company
audit_event.company_id
company.company_id
Restrict delete
fk_event_consumption_publication
event_consumption.event_id
event_consumption.company_id
event_publication.event_id
event_publication.company_id
Restrict delete
fk_worker_import_commit_idempotency_job_company
worker_import_commit_idempotency.import_id
worker_import_commit_idempotency.company_id
worker_import_job.import_id
worker_import_job.company_id
Cascade on delete
fk_ai_run_requester_company
ai_run.requested_by
ai_run.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_ai_run_company
ai_run.company_id
company.company_id
Restrict delete
fk_worker_company
worker.company_id
company.company_id
Restrict delete
fk_document_ocr_run_reviewer_company
document_ocr_run.reviewed_by
document_ocr_run.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_document_ocr_run_requester_company
document_ocr_run.requested_by
document_ocr_run.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_document_ocr_run_document_company
document_ocr_run.worker_document_id
document_ocr_run.company_id
worker_document.worker_document_id
worker_document.company_id
Restrict delete
fk_document_ocr_run_file_company
document_ocr_run.stored_file_id
document_ocr_run.company_id
stored_file.stored_file_id
stored_file.company_id
Restrict delete
fk_worker_document_upload_idempotency_link_company
worker_document_upload_idempotency.worker_link_id
worker_document_upload_idempotency.company_id
worker_link.worker_link_id
worker_link.company_id
Restrict delete
fk_worker_document_upload_idempotency_file_company
worker_document_upload_idempotency.stored_file_id
worker_document_upload_idempotency.company_id
stored_file.stored_file_id
stored_file.company_id
Restrict delete
fk_ai_question_attempt_company
ai_question.ai_attempt_id
ai_question.company_id
ai_attempt.ai_attempt_id
ai_attempt.company_id
Cascade on delete
fk_ai_question_run_company
ai_question.ai_run_id
ai_question.company_id
ai_run.ai_run_id
ai_run.company_id
Cascade on delete
fk_ai_question_answered_by_company
ai_question.answered_by
ai_question.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_worker_response_link_company
worker_response.worker_link_id
worker_response.company_id
worker_link.worker_link_id
worker_link.company_id
Restrict delete
fk_worker_response_company
worker_response.company_id
company.company_id
Restrict delete
fk_worker_archive_actor_company
worker_archive.archived_by
worker_archive.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_worker_archive_worker_company
worker_archive.worker_id
worker_archive.company_id
worker.worker_id
worker.company_id
Restrict delete
fk_task_checklist_task_company
task_checklist_item.task_id
task_checklist_item.company_id
task.task_id
task.company_id
Cascade on delete
fk_task_checklist_actor_company
task_checklist_item.completed_by
task_checklist_item.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_ai_attempt_run_company
ai_attempt.ai_run_id
ai_attempt.company_id
ai_run.ai_run_id
ai_run.company_id
Cascade on delete
fk_worker_response_upload_response_company
worker_response_upload.response_id
worker_response_upload.company_id
worker_response.response_id
worker_response.company_id
Cascade on delete
fk_worker_response_upload_file_company
worker_response_upload.stored_file_id
worker_response_upload.company_id
stored_file.stored_file_id
stored_file.company_id
Restrict delete
fk_notification_preference_user_company
notification_preference.user_id
notification_preference.company_id
user_account.user_id
user_account.company_id
Cascade on delete
fk_approval_request_task_company
approval_request.task_id
approval_request.company_id
task.task_id
task.company_id
Restrict delete
fk_approval_request_decider_company
approval_request.decided_by
approval_request.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_approval_request_requester_company
approval_request.requested_by
approval_request.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_user_account_company
user_account.company_id
company.company_id
Restrict delete
fk_outbox_manual_retry_event_company
outbox_manual_retry.event_id
outbox_manual_retry.company_id
event_publication.event_id
event_publication.company_id
Restrict delete
fk_outbox_manual_retry_actor_company
outbox_manual_retry.requested_by
outbox_manual_retry.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_task_updated_by_company
task.updated_by
task.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_task_worker_company
task.worker_id
task.company_id
worker.worker_id
worker.company_id
Restrict delete
fk_task_created_by_company
task.created_by
task.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_task_assignee_company
task.assignee_id
task.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_task_company
task.company_id
company.company_id
Restrict delete
fk_user_login_event_user_company
user_login_event.user_id
user_login_event.company_id
user_account.user_id
user_account.company_id
Cascade on delete
fk_worker_document_worker
worker_document.worker_id
worker_document.company_id
worker.worker_id
worker.company_id
Restrict delete
fk_worker_document_archived_by_company
worker_document.archived_by
worker_document.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_worker_document_task_worker_company
worker_document.task_id
worker_document.worker_id
worker_document.company_id
task.task_id
task.worker_id
task.company_id
Restrict delete
fk_worker_import_job_creator_company
worker_import_job.created_by
worker_import_job.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_worker_import_job_company
worker_import_job.company_id
company.company_id
Restrict delete
fk_worker_import_job_source_file_company
worker_import_job.source_file_id
worker_import_job.company_id
stored_file.stored_file_id
stored_file.company_id
Restrict delete
fk_stored_file_worker_company
stored_file.worker_id
stored_file.company_id
worker.worker_id
worker.company_id
Restrict delete
fk_stored_file_company
stored_file.company_id
company.company_id
Restrict delete
fk_stored_file_task_company
stored_file.task_id
stored_file.company_id
task.task_id
task.company_id
Restrict delete
fk_document_request_draft_company
document_request_draft.company_id
company.company_id
Restrict delete
fk_document_request_draft_task_company
document_request_draft.task_id
document_request_draft.company_id
task.task_id
task.company_id
Restrict delete
fk_ai_candidate_decision_task_decision_company
ai_candidate_decision_task.decision_id
ai_candidate_decision_task.company_id
ai_candidate_decision.decision_id
ai_candidate_decision.company_id
Cascade on delete
fk_ai_candidate_decision_task_task_company
ai_candidate_decision_task.task_id
ai_candidate_decision_task.company_id
task.task_id
task.company_id
Restrict delete
fk_refresh_token_replacement_family
refresh_token.replaced_by_token_id
refresh_token.token_family_id
refresh_token.refresh_token_id
refresh_token.token_family_id
Restrict delete
fk_refresh_token_user_company
refresh_token.user_id
refresh_token.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_ai_candidate_decision_batch_company
ai_candidate_decision.decision_batch_id
ai_candidate_decision.company_id
ai_candidate_decision_batch.decision_batch_id
ai_candidate_decision_batch.company_id
Cascade on delete
fk_ai_candidate_decision_candidate_company
ai_candidate_decision.ai_candidate_id
ai_candidate_decision.company_id
ai_candidate.ai_candidate_id
ai_candidate.company_id
Restrict delete
fk_ai_candidate_decision_run_company
ai_candidate_decision.ai_run_id
ai_candidate_decision.company_id
ai_run.ai_run_id
ai_run.company_id
Cascade on delete
fk_company_settings_company
company_settings.company_id
company.company_id
Cascade on delete
fk_ai_candidate_worker_company
ai_candidate.worker_id
ai_candidate.company_id
worker.worker_id
worker.company_id
Restrict delete
fk_ai_candidate_attempt_company
ai_candidate.ai_attempt_id
ai_candidate.company_id
ai_attempt.ai_attempt_id
ai_attempt.company_id
Cascade on delete
fk_ai_candidate_run_company
ai_candidate.ai_run_id
ai_candidate.company_id
ai_run.ai_run_id
ai_run.company_id
Cascade on delete
fk_task_evidence_actor_company
task_evidence.recorded_by
task_evidence.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_task_evidence_task_company
task_evidence.task_id
task_evidence.company_id
task.task_id
task.company_id
Restrict delete
fk_document_request_draft_type_draft
document_request_draft_type.draft_id
document_request_draft.draft_id
Cascade on delete
fk_user_agreement_consent_user_company
user_agreement_consent.user_id
user_agreement_consent.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_password_reset_token_user_company
password_reset_token.user_id
password_reset_token.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_workflow_case_created_by_company
workflow_case.created_by
workflow_case.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_workflow_case_company
workflow_case.company_id
company.company_id
Restrict delete
fk_workflow_case_worker_company
workflow_case.worker_id
workflow_case.company_id
worker.worker_id
worker.company_id
Cascade on delete
fk_external_submission_actor_company
external_submission.submitted_by
external_submission.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_external_submission_task_company
external_submission.task_id
external_submission.company_id
task.task_id
task.company_id
Restrict delete
fk_worker_link_issued_by_company
worker_link.issued_by
worker_link.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_worker_link_task_company
worker_link.task_id
worker_link.company_id
task.task_id
task.company_id
Restrict delete
fk_worker_link_sent_by_company
worker_link.sent_by
worker_link.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_worker_link_assignee_company
worker_link.assignee_id
worker_link.company_id
user_account.user_id
user_account.company_id
Restrict delete
fk_worker_link_replaces_company
worker_link.replaces_link_id
worker_link.company_id
worker_link.worker_link_id
worker_link.company_id
Restrict delete
fk_worker_link_company
worker_link.company_id
company.company_id
Restrict delete
fk_event_publication_company
event_publication.company_id
company.company_id
Restrict delete
fk_stay_verification_extension_receipt
stay_verification_case.extension_receipt_document_id
stay_verification_case.company_id
worker_document.worker_document_id
worker_document.company_id
Restrict delete
fk_stay_verification_worker_company
stay_verification_case.worker_id
stay_verification_case.company_id
worker.worker_id
worker.company_id
Restrict delete
fk_stay_verification_approval_result
stay_verification_case.approval_result_document_id
stay_verification_case.company_id
worker_document.worker_document_id
worker_document.company_id
Restrict delete

Check Constraints

Table Constraint Name Constraint
ai_candidate_decision_batch ck_ai_candidate_decision_batch_completion ((((completed_at IS NULL) AND (resulting_run_version IS NULL)) OR ((completed_at IS NOT NULL) AND (resulting_run_version IS NOT NULL))))
ai_candidate_decision_batch ck_ai_candidate_decision_batch_idempotency_hash ((char_length((idempotency_key_hash)::text) = 64))
ai_candidate_decision_batch ck_ai_candidate_decision_batch_payload_hash ((char_length((payload_hash)::text) = 64))
ai_candidate_decision_batch ck_ai_candidate_decision_batch_version (((resulting_run_version IS NULL) OR (resulting_run_version >= 0)))
worker_import_row ck_worker_import_row_number ((row_number >= 2))
worker_import_row ck_worker_import_row_status (((status)::text = ANY ((ARRAY['PENDING'::character varying, 'VALID'::character varying, 'INVALID'::character varying, 'EXCLUDED'::character varying, 'COMMITTED'::character varying])::text[])))
worker_import_row ck_worker_import_row_time_order ((updated_at >= created_at))
worker_import_row ck_worker_import_row_version ((version >= 0))
worker_import_row ck_worker_import_row_worker_status (((((status)::text = 'COMMITTED'::text) AND (worker_id IS NOT NULL)) OR (((status)::text <> 'COMMITTED'::text) AND (worker_id IS NULL))))
task_transition_history ck_task_transition_changed (((from_status)::text <> (to_status)::text))
task_transition_history ck_task_transition_from_status (((from_status)::text = ANY ((ARRAY['DRAFT'::character varying, 'NEEDS_INFO'::character varying, 'READY_FOR_REVIEW'::character varying, 'APPROVED'::character varying, 'WAITING_WORKER'::character varying, 'WAITING_EXTERNAL'::character varying, 'COMPLETED'::character varying, 'CANCELLED'::character varying])::text[])))
task_transition_history ck_task_transition_request_not_blank ((char_length(TRIM(BOTH FROM request_id)) > 0))
task_transition_history ck_task_transition_to_status (((to_status)::text = ANY ((ARRAY['DRAFT'::character varying, 'NEEDS_INFO'::character varying, 'READY_FOR_REVIEW'::character varying, 'APPROVED'::character varying, 'WAITING_WORKER'::character varying, 'WAITING_EXTERNAL'::character varying, 'COMPLETED'::character varying, 'CANCELLED'::character varying])::text[])))
audit_event ck_audit_event_action_not_blank ((char_length(TRIM(BOTH FROM action)) > 0))
audit_event ck_audit_event_actor_type (((actor_type)::text = ANY ((ARRAY['HR_USER'::character varying, 'WORKER_LINK'::character varying, 'AI_AGENT'::character varying, 'SYSTEM_RULE'::character varying])::text[])))
audit_event ck_audit_event_request_not_blank ((char_length(TRIM(BOTH FROM request_id)) > 0))
audit_event ck_audit_event_summary_not_blank ((char_length(TRIM(BOTH FROM change_summary)) > 0))
audit_event ck_audit_event_target_type_not_blank ((char_length(TRIM(BOTH FROM target_type)) > 0))
audit_event ck_audit_event_user_role (((user_role IS NULL) OR ((user_role)::text = ANY ((ARRAY['ADMIN'::character varying, 'HR'::character varying, 'VIEWER'::character varying])::text[]))))
audit_event ck_audit_event_version_not_blank ((char_length(TRIM(BOTH FROM event_version)) > 0))
event_consumption ck_event_consumption_handler_not_blank ((char_length(TRIM(BOTH FROM handler_name)) > 0))
worker_import_commit_idempotency ck_worker_import_commit_idempotency_key_hash ((char_length((idempotency_key_hash)::text) = 64))
worker_import_commit_idempotency ck_worker_import_commit_request_hash ((char_length((request_hash)::text) = 64))
ai_run ck_ai_run_attempt_count ((attempt_count >= 0))
ai_run ck_ai_run_idempotency_hash_length ((char_length((idempotency_key_hash)::text) = 64))
ai_run ck_ai_run_instruction_hash_length ((char_length((instruction_hash)::text) = 64))
ai_run ck_ai_run_instruction_not_blank ((char_length(TRIM(BOTH FROM instruction)) > 0))
ai_run ck_ai_run_outcome (((analysis_outcome IS NULL) OR ((analysis_outcome)::text = ANY ((ARRAY['OUT_OF_SCOPE'::character varying, 'CONTEXT_REQUIRED'::character varying, 'NEEDS_INFO'::character varying, 'REVIEW_REQUIRED'::character varying])::text[]))))
ai_run ck_ai_run_status (((status)::text = ANY ((ARRAY['QUEUED'::character varying, 'RUNNING'::character varying, 'SUCCEEDED'::character varying, 'FAILED'::character varying])::text[])))
ai_run ck_ai_run_updated_at ((updated_at >= created_at))
ai_run ck_ai_run_version ((version >= 0))
worker ck_worker_contract_period (((contract_start_date IS NULL) OR (contract_end_date IS NULL) OR (contract_end_date >= contract_start_date)))
worker ck_worker_display_name_not_blank ((char_length(TRIM(BOTH FROM display_name)) > 0))
worker ck_worker_updated_at ((updated_at >= created_at))
worker ck_worker_version ((version >= 0))
worker ck_worker_work_status (((work_status)::text = ANY ((ARRAY['ACTIVE'::character varying, 'ON_LEAVE'::character varying, 'RESIGNED'::character varying, 'TERMINATED'::character varying])::text[])))
document_ocr_run ck_document_ocr_run_correction_pair ((((corrected_fields_ciphertext IS NULL) AND (corrected_fields_key_version IS NULL)) OR ((corrected_fields_ciphertext IS NOT NULL) AND (corrected_fields_key_version IS NOT NULL))))
document_ocr_run ck_document_ocr_run_country_code (((((document_type)::text = 'PASSPORT_COPY'::text) AND (country_code IS NOT NULL) AND (char_length((country_code)::text) = 3)) OR (((document_type)::text = 'ARC'::text) AND (country_code IS NULL))))
document_ocr_run ck_document_ocr_run_document_type (((document_type)::text = ANY ((ARRAY['PASSPORT_COPY'::character varying, 'ARC'::character varying])::text[])))
document_ocr_run ck_document_ocr_run_idempotency_hash ((char_length((idempotency_key_hash)::text) = 64))
document_ocr_run ck_document_ocr_run_request_hash ((char_length((request_hash)::text) = 64))
document_ocr_run ck_document_ocr_run_result_pair ((((result_ciphertext IS NULL) AND (result_key_version IS NULL)) OR ((result_ciphertext IS NOT NULL) AND (result_key_version IS NOT NULL))))
document_ocr_run ck_document_ocr_run_review_pair ((((reviewed_by IS NULL) AND (reviewed_at IS NULL)) OR ((reviewed_by IS NOT NULL) AND (reviewed_at IS NOT NULL))))
document_ocr_run ck_document_ocr_run_review_reason (((review_reason IS NULL) OR ((char_length(TRIM(BOTH FROM review_reason)) >= 1) AND (char_length(TRIM(BOTH FROM review_reason)) <= 300))))
document_ocr_run ck_document_ocr_run_status (((status)::text = ANY ((ARRAY['QUEUED'::character varying, 'RUNNING'::character varying, 'READY_FOR_REVIEW'::character varying, 'REVIEW_REQUIRED'::character varying, 'APPROVED'::character varying, 'REJECTED'::character varying, 'FAILED'::character varying])::text[])))
document_ocr_run ck_document_ocr_run_time_order (((updated_at >= created_at) AND ((started_at IS NULL) OR (started_at >= created_at)) AND ((completed_at IS NULL) OR (completed_at >= created_at)) AND ((reviewed_at IS NULL) OR (reviewed_at >= created_at))))
document_ocr_run ck_document_ocr_run_version ((version >= 0))
worker_document_upload_idempotency ck_worker_document_upload_idempotency_hash_pair ((((idempotency_key_hash IS NULL) AND (request_hash IS NULL)) OR ((idempotency_key_hash IS NOT NULL) AND (request_hash IS NOT NULL))))
worker_document_upload_idempotency ck_worker_document_upload_idempotency_key_hash (((idempotency_key_hash IS NULL) OR (char_length((idempotency_key_hash)::text) = 64)))
worker_document_upload_idempotency ck_worker_document_upload_idempotency_request_hash (((request_hash IS NULL) OR (char_length((request_hash)::text) = 64)))
ai_question ck_ai_question_answer ((((answer_value IS NULL) AND (answered_by IS NULL) AND (answered_at IS NULL)) OR ((answer_value IS NOT NULL) AND (answered_by IS NOT NULL) AND (answered_at IS NOT NULL))))
ai_question ck_ai_question_input_type (((input_type)::text = ANY ((ARRAY['TEXT'::character varying, 'DATE'::character varying, 'NUMBER'::character varying, 'SELECT'::character varying])::text[])))
ai_question ck_ai_question_label_not_blank ((char_length(TRIM(BOTH FROM label)) > 0))
ai_question ck_ai_question_slot_not_blank ((char_length(TRIM(BOTH FROM slot_key)) > 0))
worker_response ck_worker_response_answers_json_not_blank ((char_length(TRIM(BOTH FROM answers_json)) > 0))
worker_response ck_worker_response_request_fingerprint (((request_fingerprint IS NULL) OR ((char_length((request_fingerprint)::text) = 64) AND ((request_fingerprint)::text = lower((request_fingerprint)::text)))))
worker_response ck_worker_response_type (((response_type)::text = ANY ((ARRAY['ACKNOWLEDGED'::character varying, 'QUESTION'::character varying, 'NOT_UNDERSTOOD'::character varying, 'DOCUMENT_SUBMITTED'::character varying, 'DIFFICULT'::character varying, 'SLOT_ANSWERS_SUBMITTED'::character varying])::text[])))
worker_archive ck_worker_archive_reason_not_blank ((char_length(TRIM(BOTH FROM archive_reason)) > 0))
worker_archive ck_worker_archive_worker_version ((worker_version > 0))
task_checklist_item ck_task_checklist_code_not_blank ((char_length(TRIM(BOTH FROM item_code)) > 0))
task_checklist_item ck_task_checklist_completion ((((completed = false) AND (completed_by IS NULL) AND (completed_at IS NULL)) OR ((completed = true) AND (completed_by IS NOT NULL) AND (completed_at IS NOT NULL))))
task_checklist_item ck_task_checklist_label_not_blank ((char_length(TRIM(BOTH FROM label)) > 0))
task_checklist_item ck_task_checklist_updated_at ((updated_at >= created_at))
task_checklist_item ck_task_checklist_version ((version >= 0))
ai_attempt ck_ai_attempt_completion (((((status)::text = 'RUNNING'::text) AND (completed_at IS NULL)) OR (((status)::text = ANY ((ARRAY['SUCCEEDED'::character varying, 'FAILED'::character varying])::text[])) AND (completed_at IS NOT NULL))))
ai_attempt ck_ai_attempt_context_round ((context_round >= 0))
ai_attempt ck_ai_attempt_input_not_blank ((char_length(TRIM(BOTH FROM analysis_input_json)) > 0))
ai_attempt ck_ai_attempt_latency (((latency_ms IS NULL) OR (latency_ms >= 0)))
ai_attempt ck_ai_attempt_phase (((phase)::text = ANY ((ARRAY['PLAN'::character varying, 'ANALYZE'::character varying])::text[])))
ai_attempt ck_ai_attempt_provider_count (((provider_attempt_count IS NULL) OR (provider_attempt_count >= 0)))
ai_attempt ck_ai_attempt_sequence ((sequence_no > 0))
ai_attempt ck_ai_attempt_status (((status)::text = ANY ((ARRAY['RUNNING'::character varying, 'SUCCEEDED'::character varying, 'FAILED'::character varying])::text[])))
notification_preference ck_notification_preference_key_not_blank ((char_length(TRIM(BOTH FROM pref_key)) > 0))
approval_request ck_approval_request_approved_task_version ((((status)::text <> 'APPROVED'::text) OR (approved_task_version IS NOT NULL)))
approval_request ck_approval_request_approved_version (((approved_task_version IS NULL) OR (approved_task_version >= target_task_version)))
approval_request ck_approval_request_changed_fields_not_blank ((char_length(TRIM(BOTH FROM changed_fields_json)) > 0))
approval_request 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))))
approval_request ck_approval_request_fingerprint_length ((char_length((target_fingerprint)::text) = 64))
approval_request ck_approval_request_fingerprint_lowercase (((target_fingerprint)::text = lower((target_fingerprint)::text)))
approval_request ck_approval_request_hr_snapshot_not_blank ((char_length(TRIM(BOTH FROM hr_snapshot_json)) > 0))
approval_request ck_approval_request_source_versions_not_blank ((char_length(TRIM(BOTH FROM source_versions_json)) > 0))
approval_request ck_approval_request_status (((status)::text = ANY ((ARRAY['PENDING'::character varying, 'APPROVED'::character varying, 'REJECTED'::character varying, 'INVALIDATED'::character varying])::text[])))
approval_request ck_approval_request_target_revision ((target_content_revision >= 0))
approval_request ck_approval_request_target_version ((target_task_version >= 0))
approval_request ck_approval_request_updated_at ((updated_at >= created_at))
approval_request ck_approval_request_version ((version >= 0))
user_account ck_user_account_display_name_not_blank ((char_length(TRIM(BOTH FROM display_name)) > 0))
user_account ck_user_account_email_not_blank ((char_length(TRIM(BOTH FROM email)) > 0))
user_account ck_user_account_failed_login_attempts ((failed_login_attempts >= 0))
user_account ck_user_account_normalized_email (((normalized_email)::text = lower(TRIM(BOTH FROM email))))
user_account ck_user_account_normalized_email_not_blank ((char_length(TRIM(BOTH FROM normalized_email)) > 0))
user_account ck_user_account_password_hash_not_blank ((char_length(TRIM(BOTH FROM password_hash)) > 0))
user_account ck_user_account_phone_cipher_pair ((((phone_ciphertext IS NULL) AND (phone_key_version IS NULL)) OR ((phone_ciphertext IS NOT NULL) AND (phone_key_version IS NOT NULL))))
user_account ck_user_account_phone_single_storage (((phone IS NULL) OR (phone_ciphertext IS NULL)))
user_account ck_user_account_role (((role)::text = ANY ((ARRAY['ADMIN'::character varying, 'HR'::character varying, 'VIEWER'::character varying])::text[])))
user_account ck_user_account_status (((status)::text = ANY ((ARRAY['ACTIVE'::character varying, 'SUSPENDED'::character varying, 'DISABLED'::character varying])::text[])))
user_account ck_user_account_updated_at ((updated_at >= created_at))
user_account ck_user_account_version ((version >= 0))
outbox_manual_retry ck_outbox_manual_retry_key_hash ((char_length((idempotency_key_hash)::text) = 64))
outbox_manual_retry ck_outbox_manual_retry_previous_attempt_count ((previous_attempt_count >= 0))
outbox_manual_retry ck_outbox_manual_retry_reason (((char_length(TRIM(BOTH FROM reason)) >= 10) AND (char_length(TRIM(BOTH FROM reason)) <= 300)))
outbox_manual_retry ck_outbox_manual_retry_request_hash ((char_length((request_hash)::text) = 64))
outbox_manual_retry ck_outbox_manual_retry_request_id (((char_length(TRIM(BOTH FROM request_id)) >= 1) AND (char_length(TRIM(BOTH FROM request_id)) <= 128)))
outbox_manual_retry ck_outbox_manual_retry_status (((accepted_status)::text = 'PENDING'::text))
outbox_manual_retry ck_outbox_manual_retry_trace_id (((trace_id IS NULL) OR (char_length((trace_id)::text) = 32)))
outbox_manual_retry ck_outbox_manual_retry_version ((accepted_version >= 0))
task ck_task_business_data_not_blank ((char_length(TRIM(BOTH FROM business_data_json)) > 0))
task ck_task_catalog_version_not_blank ((char_length(TRIM(BOTH FROM workflow_catalog_version)) > 0))
task ck_task_content_revision ((content_revision >= 0))
task ck_task_fingerprint_length ((char_length((critical_fingerprint)::text) = 64))
task ck_task_fingerprint_lowercase (((critical_fingerprint)::text = lower((critical_fingerprint)::text)))
task ck_task_source (((source)::text = ANY ((ARRAY['MANUAL'::character varying, 'SYSTEM_DDAY'::character varying, 'AI_CANDIDATE'::character varying, 'FILE_IMPORT'::character varying, 'WORKER_RESPONSE'::character varying])::text[])))
task ck_task_status (((status)::text = ANY ((ARRAY['DRAFT'::character varying, 'NEEDS_INFO'::character varying, 'READY_FOR_REVIEW'::character varying, 'APPROVED'::character varying, 'WAITING_WORKER'::character varying, 'WAITING_EXTERNAL'::character varying, 'COMPLETED'::character varying, 'CANCELLED'::character varying])::text[])))
task ck_task_target (((((target_type)::text = 'WORKER'::text) AND (worker_id IS NOT NULL) AND (case_id IS NOT NULL)) OR (((target_type)::text = 'COMPANY'::text) AND (worker_id IS NULL) AND (case_id IS NULL))))
task ck_task_title_not_blank ((char_length(TRIM(BOTH FROM title)) > 0))
task ck_task_type (((task_type)::text = ANY ((ARRAY['RECONTRACT'::character varying, 'EMPLOYMENT_PERIOD_EXTENSION'::character varying, 'STAY_PERIOD_EXTENSION'::character varying, 'DOCUMENT_REQUEST'::character varying, 'WORKER_ONBOARDING'::character varying, 'PAYROLL_EXPLANATION'::character varying, 'EMPLOYMENT_CHANGE'::character varying, 'WORK_INSTRUCTION'::character varying])::text[])))
task ck_task_updated_at ((updated_at >= created_at))
task ck_task_version ((version >= 0))
task ck_task_workflow_id_not_blank ((char_length(TRIM(BOTH FROM workflow_id)) > 0))
user_login_event ck_user_login_event_device_summary_not_blank ((char_length(TRIM(BOTH FROM device_summary)) > 0))
worker_document ck_worker_document_archive_metadata ((((archived_at IS NULL) AND (archived_by IS NULL) AND (archive_reason IS NULL)) OR ((archived_at IS NOT NULL) AND (archived_by IS NOT NULL) AND (archive_reason IS NOT NULL) AND (char_length(TRIM(BOTH FROM archive_reason)) > 0))))
worker_document ck_worker_document_issue_expiry (((issue_date IS NULL) OR (expiry_date IS NULL) OR (expiry_date >= issue_date)))
worker_document ck_worker_document_source (((source)::text = ANY ((ARRAY['LEGACY'::character varying, 'DEMO_SEED'::character varying, 'HR_UPLOAD'::character varying, 'WORKER_UPLOAD'::character varying, 'AI_GENERATED'::character varying])::text[])))
worker_document ck_worker_document_submission_status (((submission_status)::text = ANY ((ARRAY['DRAFT'::character varying, 'MISSING'::character varying, 'SUBMITTED'::character varying, 'VERIFIED'::character varying])::text[])))
worker_document ck_worker_document_type (((document_type)::text = ANY ((ARRAY['PASSPORT_COPY'::character varying, 'ARC'::character varying, 'CONTRACT'::character varying, 'PERMIT'::character varying, 'EMPLOYMENT_EXTENSION_APPLICATION'::character varying, 'INTEGRATED_APPLICATION'::character varying, 'IDENTITY_GUARANTY'::character varying, 'RESIDENCE_PROOF'::character varying])::text[])))
worker_document ck_worker_document_updated_at ((updated_at >= created_at))
worker_document ck_worker_document_version ((version >= 0))
worker_import_job ck_worker_import_job_counts (((total_rows >= 0) AND (valid_rows >= 0) AND (invalid_rows >= 0) AND (excluded_rows >= 0) AND (committed_rows >= 0) AND ((((valid_rows + invalid_rows) + excluded_rows) + committed_rows) <= total_rows)))
worker_import_job ck_worker_import_job_create_key_hash ((char_length((create_idempotency_key_hash)::text) = 64))
worker_import_job ck_worker_import_job_create_request_hash ((char_length((create_request_hash)::text) = 64))
worker_import_job ck_worker_import_job_status (((status)::text = ANY ((ARRAY['UPLOADED'::character varying, 'MAPPED'::character varying, 'REVIEW_REQUIRED'::character varying, 'READY'::character varying, 'COMMITTED'::character varying])::text[])))
worker_import_job ck_worker_import_job_time_order (((updated_at >= created_at) AND (source_file_expires_at > created_at)))
worker_import_job ck_worker_import_job_version ((version >= 0))
stored_file ck_stored_file_checksum_sha256 (((checksum_sha256 IS NULL) OR ((char_length((checksum_sha256)::text) = 64) AND ((checksum_sha256)::text = lower((checksum_sha256)::text)))))
stored_file ck_stored_file_mime_type_not_blank ((char_length(TRIM(BOTH FROM mime_type)) > 0))
stored_file ck_stored_file_name_not_blank ((char_length(TRIM(BOTH FROM name)) > 0))
stored_file ck_stored_file_purpose_not_blank ((char_length(TRIM(BOTH FROM purpose)) > 0))
stored_file ck_stored_file_scan_status (((scan_status)::text = 'NOT_SCANNED'::text))
stored_file ck_stored_file_size_positive ((size > 0))
document_request_draft ck_document_request_draft_language_not_blank ((char_length(TRIM(BOTH FROM language)) > 0))
document_request_draft ck_document_request_draft_review_status (((review_status)::text = 'DRAFT'::text))
document_request_draft ck_document_request_draft_updated_at ((updated_at >= created_at))
document_request_draft ck_document_request_draft_version ((version >= 0))
ai_candidate_decision_task ck_ai_candidate_decision_task_sequence ((sequence_no > 0))
refresh_token ck_refresh_token_expiry ((expires_at > created_at))
refresh_token ck_refresh_token_hash_length ((char_length((token_hash)::text) = 64))
refresh_token ck_refresh_token_hash_lowercase (((token_hash)::text = lower((token_hash)::text)))
refresh_token ck_refresh_token_replacement (((replaced_by_token_id IS NULL) OR (replaced_by_token_id <> refresh_token_id)))
refresh_token ck_refresh_token_replacement_used (((replaced_by_token_id IS NULL) OR (used_at IS NOT NULL)))
refresh_token ck_refresh_token_revoked_at (((revoked_at IS NULL) OR (revoked_at >= created_at)))
refresh_token ck_refresh_token_updated_at (((updated_at >= created_at) AND ((used_at IS NULL) OR (updated_at >= used_at)) AND ((revoked_at IS NULL) OR (updated_at >= revoked_at))))
refresh_token ck_refresh_token_used_at (((used_at IS NULL) OR (used_at >= created_at)))
refresh_token ck_refresh_token_version ((version >= 0))
ai_candidate_decision ck_ai_candidate_decision_action (((action)::text = ANY ((ARRAY['ACCEPT'::character varying, 'DISCARD'::character varying])::text[])))
company ck_company_name_not_blank ((char_length(TRIM(BOTH FROM name)) > 0))
company ck_company_status (((status)::text = ANY ((ARRAY['ACTIVE'::character varying, 'SUSPENDED'::character varying, 'DISABLED'::character varying])::text[])))
company ck_company_updated_at ((updated_at >= created_at))
company ck_company_version ((version >= 0))
company_settings ck_company_settings_ai_log_retention_days (((ai_log_retention_days >= 7) AND (ai_log_retention_days <= 365)))
company_settings ck_company_settings_approval_policy (((approval_policy)::text = ANY ((ARRAY['ADMIN_ONLY'::character varying, 'ADMIN_OR_HR'::character varying])::text[])))
company_settings ck_company_settings_audit_visibility (((audit_visibility)::text = ANY ((ARRAY['ADMIN_ONLY'::character varying, 'ADMIN_AND_HR'::character varying])::text[])))
company_settings ck_company_settings_evidence_rules_json_not_blank ((char_length(TRIM(BOTH FROM evidence_rules_json)) > 0))
company_settings ck_company_settings_file_retention_days (((file_retention_days >= 30) AND (file_retention_days <= 3650)))
company_settings ck_company_settings_link_expiry_hours (((link_expiry_hours >= 1) AND (link_expiry_hours <= 168)))
company_settings ck_company_settings_time_order ((updated_at >= created_at))
company_settings ck_company_settings_version ((version >= 0))
ai_candidate ck_ai_candidate_confidence (((confidence >= (0)::numeric) AND (confidence <= (1)::numeric)))
ai_candidate ck_ai_candidate_extracted_not_blank ((char_length(TRIM(BOTH FROM extracted_slots_json)) > 0))
ai_candidate ck_ai_candidate_missing_not_blank ((char_length(TRIM(BOTH FROM missing_slots_json)) > 0))
ai_candidate ck_ai_candidate_ref_not_blank ((char_length(TRIM(BOTH FROM candidate_ref)) > 0))
ai_candidate ck_ai_candidate_workflow_not_blank ((char_length(TRIM(BOTH FROM workflow_id)) > 0))
task_evidence ck_task_evidence_content ((((file_reference IS NOT NULL) AND (char_length(TRIM(BOTH FROM file_reference)) > 0)) OR ((note IS NOT NULL) AND (char_length(TRIM(BOTH FROM note)) > 0))))
task_evidence ck_task_evidence_created_at ((created_at >= recorded_at))
task_evidence ck_task_evidence_type (((evidence_type)::text = ANY ((ARRAY['DOCUMENT'::character varying, 'RECEIPT'::character varying, 'OFFICIAL_RESULT'::character varying, 'HR_CONFIRMATION'::character varying])::text[])))
document_request_draft_type ck_document_request_draft_type_value (((document_type)::text = ANY ((ARRAY['PASSPORT_COPY'::character varying, 'ARC'::character varying, 'CONTRACT'::character varying, 'PERMIT'::character varying])::text[])))
user_agreement_consent ck_user_agreement_consent_request_not_blank ((char_length(TRIM(BOTH FROM request_id)) > 0))
user_agreement_consent ck_user_agreement_consent_type (((agreement_type)::text = ANY ((ARRAY['SERVICE_TERMS'::character varying, 'PRIVACY_POLICY'::character varying, 'MARKETING'::character varying])::text[])))
user_agreement_consent ck_user_agreement_consent_version_not_blank ((char_length(TRIM(BOTH FROM policy_version)) > 0))
password_reset_token ck_password_reset_token_expiry ((expires_at > created_at))
password_reset_token ck_password_reset_token_hash_length ((char_length((token_hash)::text) = 64))
password_reset_token ck_password_reset_token_hash_lowercase (((token_hash)::text = lower((token_hash)::text)))
password_reset_token ck_password_reset_token_updated_at (((updated_at >= created_at) AND ((used_at IS NULL) OR (updated_at >= used_at))))
password_reset_token ck_password_reset_token_used_at (((used_at IS NULL) OR (used_at >= created_at)))
password_reset_token ck_password_reset_token_version ((version >= 0))
workflow_case ck_workflow_case_catalog_version_not_blank ((char_length(TRIM(BOTH FROM workflow_catalog_version)) > 0))
workflow_case ck_workflow_case_lifecycle_status (((lifecycle_status)::text = ANY ((ARRAY['ACTIVE'::character varying, 'COMPLETED'::character varying, 'CANCELLED'::character varying])::text[])))
workflow_case ck_workflow_case_priority (((priority)::text = ANY ((ARRAY['URGENT'::character varying, 'HIGH'::character varying, 'NORMAL'::character varying, 'LOW'::character varying])::text[])))
workflow_case ck_workflow_case_snapshot_not_blank ((char_length(TRIM(BOTH FROM workflow_snapshot_json)) > 0))
workflow_case ck_workflow_case_title_not_blank ((char_length(TRIM(BOTH FROM title)) > 0))
workflow_case ck_workflow_case_updated_at ((updated_at >= created_at))
workflow_case ck_workflow_case_version ((version >= 0))
external_submission ck_external_submission_created_at ((created_at >= submitted_at))
external_submission ck_external_submission_destination_not_blank ((char_length(TRIM(BOTH FROM destination)) > 0))
external_submission ck_external_submission_reference_not_blank ((char_length(TRIM(BOTH FROM safe_reference)) > 0))
worker_link ck_worker_link_conversation_status (((conversation_status)::text = ANY ((ARRAY['WAITING_WORKER'::character varying, 'NEEDS_FOLLOWUP'::character varying, 'REOPENED'::character varying])::text[])))
worker_link ck_worker_link_delivery_state (((((delivery_status)::text = ANY ((ARRAY['NOT_SENT'::character varying, 'SENDING'::character varying, 'REVIEW_REQUIRED'::character varying])::text[])) AND (sent_at IS NULL) AND (sent_by IS NULL)) OR (((delivery_status)::text = 'SENT'::text) AND (sent_at IS NOT NULL) AND (sent_by IS NOT NULL))))
worker_link ck_worker_link_delivery_status (((delivery_status)::text = ANY ((ARRAY['NOT_SENT'::character varying, 'SENDING'::character varying, 'REVIEW_REQUIRED'::character varying, 'SENT'::character varying])::text[])))
worker_link ck_worker_link_expiry ((expires_at > created_at))
worker_link ck_worker_link_hash_length ((char_length((token_hash)::text) = 64))
worker_link ck_worker_link_hash_lowercase (((token_hash)::text = lower((token_hash)::text)))
worker_link ck_worker_link_status (((status)::text = ANY ((ARRAY['ACTIVE'::character varying, 'EXPIRED'::character varying, 'REVOKED'::character varying])::text[])))
worker_link ck_worker_link_updated_at ((updated_at >= created_at))
worker_link ck_worker_link_version ((version >= 0))
event_publication ck_event_publication_actor_type (((actor_type)::text = ANY ((ARRAY['HR_USER'::character varying, 'WORKER_LINK'::character varying, 'AI_AGENT'::character varying, 'SYSTEM_RULE'::character varying])::text[])))
event_publication ck_event_publication_aggregate_type_not_blank ((char_length(TRIM(BOTH FROM aggregate_type)) > 0))
event_publication ck_event_publication_attempt_count ((attempt_count >= 0))
event_publication ck_event_publication_completed (((((status)::text = 'COMPLETED'::text) AND (completed_at IS NOT NULL)) OR (((status)::text <> 'COMPLETED'::text) AND (completed_at IS NULL))))
event_publication ck_event_publication_error (((((status)::text = ANY ((ARRAY['RETRY_WAIT'::character varying, 'REVIEW_REQUIRED'::character varying])::text[])) AND (last_error_code IS NOT NULL) AND (char_length(TRIM(BOTH FROM last_error_code)) > 0)) OR (((status)::text <> ALL ((ARRAY['RETRY_WAIT'::character varying, 'REVIEW_REQUIRED'::character varying])::text[])) AND (last_error_code IS NULL))))
event_publication ck_event_publication_lease (((((status)::text = 'PROCESSING'::text) AND (lease_owner IS NOT NULL) AND (char_length(TRIM(BOTH FROM lease_owner)) > 0) AND (lease_expires_at IS NOT NULL)) OR (((status)::text <> 'PROCESSING'::text) AND (lease_owner IS NULL) AND (lease_expires_at IS NULL))))
event_publication ck_event_publication_next_attempt (((((status)::text = ANY ((ARRAY['PENDING'::character varying, 'RETRY_WAIT'::character varying])::text[])) AND (next_attempt_at IS NOT NULL)) OR (((status)::text <> ALL ((ARRAY['PENDING'::character varying, 'RETRY_WAIT'::character varying])::text[])) AND (next_attempt_at IS NULL))))
event_publication ck_event_publication_payload_not_blank ((char_length(TRIM(BOTH FROM payload_json)) > 0))
event_publication ck_event_publication_payload_version_not_blank ((char_length(TRIM(BOTH FROM payload_version)) > 0))
event_publication ck_event_publication_request_not_blank ((char_length(TRIM(BOTH FROM request_id)) > 0))
event_publication ck_event_publication_status (((status)::text = ANY ((ARRAY['PENDING'::character varying, 'PROCESSING'::character varying, 'RETRY_WAIT'::character varying, 'COMPLETED'::character varying, 'REVIEW_REQUIRED'::character varying])::text[])))
event_publication ck_event_publication_timestamps (((created_at >= occurred_at) AND (updated_at >= created_at)))
event_publication ck_event_publication_type_not_blank ((char_length(TRIM(BOTH FROM event_type)) > 0))
event_publication ck_event_publication_version ((version >= 0))
stay_verification_case ck_stay_verification_new_expiry (((new_stay_expiry_date IS NULL) OR (new_stay_expiry_date > source_stay_expiry_date)))
stay_verification_case ck_stay_verification_note (((official_consultation_note IS NULL) OR (char_length(TRIM(BOTH FROM official_consultation_note)) > 0)))
stay_verification_case ck_stay_verification_status (((verification_status)::text = ANY ((ARRAY['APPROVED'::character varying, 'APPLICATION_PENDING'::character varying, 'UNKNOWN'::character varying, 'NOT_APPLIED'::character varying, 'EMPLOYMENT_ENDED'::character varying])::text[])))
stay_verification_case ck_stay_verification_updated_at ((updated_at >= created_at))
stay_verification_case ck_stay_verification_version ((version >= 0))