USE provisioning;
set autocommit=0;

INSERT INTO voip_preferences (
  voip_preference_groups_id,
  attribute, label, type, max_occur,
  usr_pref, prof_pref, dom_pref, peer_pref, contract_pref,
  contract_location_pref, dev_pref, devprof_pref,
  modify_timestamp, internal, expose_to_customer, data_type, read_only,
  description
) VALUES (
  (SELECT id FROM voip_preference_groups WHERE NAME = 'Internals'),
  'advice_of_charge', 'Advice of charge type', 0, 1,
  1, 0, 1, 0, 1,
  0, 0, 0,
  now(), 0, 1, 'enum', 0,
  'Define the way "advice of charge" message will be sent.'
);

SELECT id FROM voip_preferences WHERE attribute='advice_of_charge' INTO @aoc_attr_id;

INSERT INTO voip_preferences_enum
(preference_id, label, value, usr_pref, dom_pref, prof_pref, peer_pref, contract_pref, contract_location_pref, default_val)
VALUES
(@aoc_attr_id, 'no', NULL,             1, 1, 0, 0, 1, 0, 1),
(@aoc_attr_id, 'Currency', 'currency', 1, 1, 0, 0, 1, 0, 0),
(@aoc_attr_id, 'Pulse', 'pulse',       1, 1, 0, 0, 1, 0, 0);

ALTER TABLE billing.billing_profiles ADD COLUMN `advice_of_charge`  tinyint(1) NOT NULL DEFAULT '0';
commit;