Columns
| Column | Type | Size | Nulls | Auto | Default | Children | Parents | Comments | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| id | uuid | 2147483647 | gen_random_uuid() |
|
|
||||||
| patient_package_instance_id | uuid | 2147483647 | null |
|
|
||||||
| patient_package_item_balance_id | uuid | 2147483647 | √ | null |
|
|
|||||
| package_definition_id | uuid | 2147483647 | null |
|
|
||||||
| package_item_id | uuid | 2147483647 | √ | null |
|
|
|||||
| event_kind | text | 2147483647 | null |
|
|
||||||
| quantity_delta | int4 | 10 | null |
|
|
||||||
| remaining_quantity_after | int4 | 10 | √ | null |
|
|
|||||
| source_kind | text | 2147483647 | null |
|
|
||||||
| source_id | text | 2147483647 | √ | null |
|
|
|||||
| source_context | jsonb | 2147483647 | '{}'::jsonb |
|
|
||||||
| actor_user_id | text | 2147483647 | √ | null |
|
|
|||||
| reason | text | 2147483647 | √ | null |
|
|
|||||
| idempotency_key | text | 2147483647 | √ | null |
|
|
|||||
| occurred_at | timestamptz | 35,6 | now() |
|
|
||||||
| created_at | timestamptz | 35,6 | now() |
|
|
Indexes
| Constraint Name | Type | Sort | Column(s) |
|---|---|---|---|
| package_ledger_entries_pkey | Primary key | Asc | id |
| package_ledger_entries_idempotency_unique | Must be unique | Asc | idempotency_key |
| package_ledger_entries_instance_idx | Performance | Asc/Asc | patient_package_instance_id + occurred_at |
| package_ledger_entries_source_idx | Performance | Asc/Asc | source_kind + source_id |
Check Constraints
| Constraint Name | Constraint |
|---|---|
| package_ledger_entries_check1 | ((((patient_package_item_balance_id IS NULL) AND (remaining_quantity_after IS NULL)) OR ((patient_package_item_balance_id IS NOT NULL) AND (remaining_quantity_after IS NOT NULL)))) |
| package_ledger_entries_remaining_quantity_after_check | (((remaining_quantity_after IS NULL) OR (remaining_quantity_after >= 0))) |
| package_ledger_entries_check | ((((event_kind = 'purchase'::text) AND (quantity_delta > 0)) OR ((event_kind = 'redemption'::text) AND (quantity_delta < 0)) OR ((event_kind = ANY (ARRAY['void'::text, 'refund'::text, 'expiration'::text])) AND (quantity_delta <= 0)) OR ((event_kind = 'adjustment'::text) AND (quantity_delta <> 0)))) |
| package_ledger_entries_source_kind_check | ((source_kind = ANY (ARRAY['checkout'::text, 'invoice'::text, 'payment'::text, 'manual'::text, 'system'::text, 'migration'::text]))) |
| package_ledger_entries_event_kind_check | ((event_kind = ANY (ARRAY['purchase'::text, 'redemption'::text, 'adjustment'::text, 'void'::text, 'refund'::text, 'expiration'::text]))) |



