Columns
| Column | Type | Size | Nulls | Auto | Default | Children | Parents | Comments | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| id | uuid | 2147483647 | gen_random_uuid() |
|
|
||||||
| gift_card_id | uuid | 2147483647 | null |
|
|
||||||
| event_kind | text | 2147483647 | null |
|
|
||||||
| amount_delta_cents | int4 | 10 | null |
|
|
||||||
| balance_after_cents | 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) |
|---|---|---|---|
| gift_card_ledger_entries_pkey | Primary key | Asc | id |
| gift_card_ledger_entries_card_idx | Performance | Asc/Desc | gift_card_id + occurred_at |
| gift_card_ledger_entries_idempotency_unique | Must be unique | Asc | idempotency_key |
| gift_card_ledger_entries_source_idx | Performance | Asc/Asc | source_kind + source_id |
Check Constraints
| Constraint Name | Constraint |
|---|---|
| gift_card_ledger_entries_check | ((((event_kind = ANY (ARRAY['issue'::text, 'reload'::text])) AND (amount_delta_cents > 0)) OR ((event_kind = ANY (ARRAY['redemption'::text, 'void'::text, 'refund'::text])) AND (amount_delta_cents < 0)) OR ((event_kind = 'adjustment'::text) AND (amount_delta_cents <> 0)))) |
| gift_card_ledger_entries_event_kind_check | ((event_kind = ANY (ARRAY['issue'::text, 'redemption'::text, 'reload'::text, 'adjustment'::text, 'void'::text, 'refund'::text]))) |
| gift_card_ledger_entries_balance_after_cents_check | ((balance_after_cents >= 0)) |
| gift_card_ledger_entries_source_kind_check | ((source_kind = ANY (ARRAY['checkout'::text, 'invoice'::text, 'payment'::text, 'manual'::text, 'system'::text]))) |



