gift_cards


Columns

Column Type Size Nulls Auto Default Children Parents Comments
id uuid 2147483647 gen_random_uuid()
gift_card_ledger_entries.gift_card_id gift_card_ledger_entries_gift_card_id_fkey R
gift_card_definition_id uuid 2147483647 null
gift_card_definitions.id gift_cards_gift_card_definition_id_fkey R
practice_id text 2147483647 null
schema_migrations.id Implied Constraint R
patient_id text 2147483647 null
schema_migrations.id Implied Constraint R
location_id text 2147483647 null
schema_migrations.id Implied Constraint R
card_number text 2147483647 null
card_number_hash text 2147483647 null
card_number_last4 text 2147483647 null
original_amount_cents int4 10 null
current_balance_cents int4 10 null
currency_code bpchar 3 'USD'::bpchar
status text 2147483647 'active'::text
issued_at timestamptz 35,6 now()
created_at timestamptz 35,6 now()
updated_at timestamptz 35,6 now()

Indexes

Constraint Name Type Sort Column(s)
gift_cards_pkey Primary key Asc id
gift_cards_definition_idx Performance Asc gift_card_definition_id
gift_cards_number_hash_unique Must be unique Asc card_number_hash
gift_cards_patient_status_idx Performance Asc/Asc/Asc practice_id + patient_id + status

Check Constraints

Constraint Name Constraint
gift_cards_original_amount_cents_check ((original_amount_cents > 0))
gift_cards_check ((current_balance_cents <= original_amount_cents))
gift_cards_current_balance_cents_check ((current_balance_cents >= 0))
gift_cards_currency_code_check ((currency_code ~ '^[A-Z]{3}$'::text))
gift_cards_status_check ((status = ANY (ARRAY['active'::text, 'exhausted'::text, 'voided'::text, 'refunded'::text])))

Relationships