3. Enum preferences

All tables are in database "provisioning".

So called "enum preferences" allow a fixed set of possible values, an enumeration, for preferences. Following the differences between other preferences are described.

Setting the attribute "data_type" of table "voip_preferences" to "enum" marks a preferences as an enum. The list of possible options is stored in table "voip_preferences_enum".

voip_preferences_enum is:

id
    boring pkey
preference_id
    Reference to table voip_preferences.
label
    A label to be displayed in frontends.
value
    Value that will be written to voip_[usr|dom|peer]_preferences.value
    if it is NOT NULL. Will not be written if it IS NULL. This can be
    used to implement a "default value" for a preference that is visible
    in frontends as such (will be listed first if nothing is actually
    selected), but will not be written to
    voip_[usr|dom|peer]_preferences.value. Usually forcing a domain or peer
    default. Should also be named clearly (eg. __"use domain default"__).
    (Note: Therefore will also not be written to any kamailio table.)
usr_pref
dom_pref
peer_pref
    Flag if this is to be used for [usr|dom|peer] preferences.
default_val
    Flag indicating if this should be used as a default value when
    creating new entities or introducing new enum preferences (both done
    via triggers). (Note: For this to work, value must also be set.)

Relevant triggers:

enum_update
    Propagates changes of voip_preferences_enum.value to
    voip_[usr|dom|peer]_preferences.value
enum_set_default
    Will create entries for default values when adding a new enum
    preference. The default value is the tuple from voip_preferences_enum
    WHERE default_val=1 AND value NOT NULL.
trigger voip_dom_crepl_trig
trigger voip_phost_crepl_trig
trigger voip_sub_crepl_trig
    These three triggers will set possible default values (same condition
    as for enum_set_default) when creating new subscribers/domains/peers.

Find a usage example in a section in db-schema/db_scripts/diff/9086.up.