hr.documents
Schema: hr
English table: hr.documents
Italian original table: hr.in_documents
Description: Core table for all document instances (requests, justifications, etc.) and their workflow state.
Overview
- Columns: 20
- Primary key: id
- Outgoing foreign keys: 3
- Incoming foreign keys: 3
- Indexes: 11
Columns
| English column | Italian original column | Type | Null | Default / Generated | Description |
|---|---|---|---|---|---|
id | id | integer | NO | Internal surrogate primary key. | |
doc_id | doc_id | integer | NO | Unique document identifier within a tenant. | |
doc_created_date | doc_cr_date | date | NO | Date when the document was created. | |
doc_created_time | doc_cr_time | integer | NO | Time of creation (integer format). | |
doc_document_model_id | doc_dm_id | integer | NO | Reference to the document model/type. | |
doc_status_code | doc_status | numeric(1,0) | NO | Current status code of the document. | |
doc_workflow_step | doc_step | numeric(1,0) | NO | Current step in the workflow sequence. | |
doc_creator_employment_id | doc_cr_rap_id | integer | NO | Reference to the employment that created the document. | |
doc_subject_employment_id | doc_rif_rap_id | integer | NO | Reference to the employment the document refers to. | |
doc_current_holder_id | doc_det_id | integer | NO | Reference to the current owner/holder in the workflow. | |
doc_payload_data | doc_data | text | NO | Content or serialized data of the document. | |
doc_valid_from | doc_dal | date | NO | Start date of the document validity period. | |
doc_valid_to | doc_al | date | NO | End date of the document validity period. | |
doc_is_read | doc_letto | boolean | NO | Flag indicating if the document has been read by the current holder. | |
doc_description | doc_description | character varying(250) | NO | Descriptive text for the document. | |
doc_required_date | doc_date_required | date | NO | The date by which the document or action is required. | |
tenant_id | tenant_id | integer | YES | Tenant identifier for data isolation. | |
colcustom | colcustom | jsonb | YES | '{}'::jsonb | JSON field for custom data. |
_deleted | _deleted | boolean | YES | false | Technical soft delete flag. |
doc_validity_period | doc_periodo | daterange | YES | GENERATED: daterange(doc_valid_from, doc_valid_to, '[]'::text) | Generated daterange for the document validity period. |
Relationships
Outgoing foreign keys
| Constraint | Local columns | References | Referenced columns | On update | On delete |
|---|---|---|---|---|---|
fk_documents_model | doc_document_model_id, tenant_id | hr.document_models | dmdl_id, tenant_id | RESTRICT | RESTRICT |
fk_documents_subject_employment | doc_subject_employment_id, tenant_id | hr.employment_relationships | er_id, tenant_id | RESTRICT | CASCADE |
fk_documents_tenant | tenant_id | cloud.tenants | ten_internal_id | RESTRICT | CASCADE |
Referenced by
| From table | Foreign key | Source columns | Target columns |
|---|---|---|---|
hr.in_documents_log | fk_doc_id | docl_doc_id, tenant_id | doc_id, tenant_id |
pres.employee_clockings | fk_timbra_tim_doc_id_to_documents | tenant_id, ec_document_id | tenant_id, doc_id |
pres.long_term_absences | fk_giustif_arg_doc_id_to_documenti | tenant_id, lta_document_id | tenant_id, doc_id |
Constraints
- Primary key:
pk_documents→id - Unique:
in_documents_tenant_id_key→tenant_id, doc_id - Unique:
uk_documents_id→doc_id, tenant_id
Indexes
| Name | Unique | Method | Columns / expression |
|---|---|---|---|
idx_doc_creator_employment_tenant | NO | btree | tenant_id, doc_creator_employment_id) WHERE (_deleted = false |
idx_doc_current_holder_tenant | NO | btree | tenant_id, doc_current_holder_id) WHERE (_deleted = false |
idx_doc_id_tenant | NO | btree | tenant_id, doc_id) WHERE (_deleted = false |
idx_doc_model_tenant | NO | btree | tenant_id, doc_document_model_id) WHERE (_deleted = false |
idx_doc_status_tenant | NO | btree | tenant_id, doc_status_code) WHERE (_deleted = false |
idx_doc_subject_employment_start_tenant | NO | btree | tenant_id, doc_subject_employment_id, doc_valid_from, doc_status_code) WHERE (_deleted = false |
idx_doc_subject_employment_tenant | NO | btree | tenant_id, doc_subject_employment_id) WHERE (_deleted = false |
idx_doc_tenant | NO | btree | tenant_id |
idx_doc_tenant_employment_period_status_gist | NO | gist | tenant_id, doc_subject_employment_id, doc_validity_period, doc_status_code) WHERE (_deleted = false |
idx_doc_tenant_employment_period_status_pending_gist | NO | gist | tenant_id, doc_subject_employment_id, doc_validity_period, doc_status_code) WHERE ((_deleted = false) AND (doc_status_code < (3)::numeric) |
idx_doc_tenant_period_gist | NO | gist | tenant_id, doc_validity_period) WHERE (_deleted = false |
Navigation
- Back to main index
- [Back to
hrindex]../)