promotion_definitions


Columns

Column Type Size Nulls Auto Default Children Parents Comments
id uuid 2147483647 gen_random_uuid()
promotion_applications.promotion_definition_id promotion_applications_promotion_definition_id_fkey R
promotion_linked_items.promotion_definition_id promotion_linked_items_promotion_definition_id_fkey C
practice_id text 2147483647 null
schema_migrations.id Implied Constraint R
name text 2147483647 null
description text 2147483647 √ null
discount_type text 2147483647 null
discount_percent numeric 7,4 √ null
discount_amount_cents int4 10 √ null
currency_code bpchar 3 'USD'::bpchar
is_active bool 1 true
starts_at timestamptz 35,6 √ null
ends_at timestamptz 35,6 √ null
created_at timestamptz 35,6 now()
updated_at timestamptz 35,6 now()

Indexes

Constraint Name Type Sort Column(s)
promotion_definitions_pkey Primary key Asc id
promotion_definitions_practice_active_idx Performance Asc/Asc/Asc/Asc practice_id + is_active + starts_at + ends_at
promotion_definitions_practice_name_unique Must be unique Asc practice_id

Check Constraints

Constraint Name Constraint
promotion_definitions_discount_type_check ((discount_type = ANY (ARRAY['percent'::text, 'fixed_amount'::text])))
promotion_definitions_currency_code_check ((currency_code ~ '^[A-Z]{3}$'::text))
promotion_definitions_check (((ends_at IS NULL) OR (starts_at IS NULL) OR (ends_at > starts_at)))
promotion_definitions_discount_amount_cents_check (((discount_amount_cents IS NULL) OR (discount_amount_cents > 0)))
promotion_definitions_name_check ((name <> ''::text))
promotion_definitions_check1 ((((discount_type = 'percent'::text) AND (discount_percent IS NOT NULL) AND (discount_amount_cents IS NULL)) OR ((discount_type = 'fixed_amount'::text) AND (discount_amount_cents IS NOT NULL) AND (discount_percent IS NULL))))
promotion_definitions_discount_percent_check (((discount_percent IS NULL) OR ((discount_percent > (0)::numeric) AND (discount_percent <= (100)::numeric))))

Relationships