From 4dcc2ffdfc41488b6bc51b0898cebbfc7cdb4444 Mon Sep 17 00:00:00 2001
From: Kirill Solomko <ksolomko@sipwise.com>
Date: Thu, 10 Sep 2015 17:27:18 +0200
Subject: [PATCH] MT#12707 - add 'identifier' domain and peer preference       
   - add 'source' field for accounting.malicious_calls

Change-Id: I65eed3657fe6f9c37350529c923715728711c2d5
---
 db_scripts/diff/15191.down | 11 +++++++++++
 db_scripts/diff/15191.up   | 11 +++++++++++
 2 files changed, 22 insertions(+)
 create mode 100644 db_scripts/diff/15191.down
 create mode 100644 db_scripts/diff/15191.up

diff --git a/db_scripts/diff/15191.down b/db_scripts/diff/15191.down
new file mode 100644
index 00000000..f11565c3
--- /dev/null
+++ b/db_scripts/diff/15191.down
@@ -0,0 +1,11 @@
+set autocommit=0;
+use accounting;
+
+ALTER TABLE accounting.malicious_calls DROP COLUMN source;
+
+SELECT id into @vp_id FROM provisioning.voip_preferences where attribute = 'identifier';
+DELETE FROM provisioning.voip_dom_preferences WHERE attribute_id = @vp_id;
+DELETE FROM provisioning.voip_peer_preferences WHERE attribute_id = @vp_id;
+DELETE FROM provisioning.voip_preferences WHERE attribute = 'identifier';
+
+commit;
diff --git a/db_scripts/diff/15191.up b/db_scripts/diff/15191.up
new file mode 100644
index 00000000..66b25b02
--- /dev/null
+++ b/db_scripts/diff/15191.up
@@ -0,0 +1,11 @@
+set autocommit=0;
+use accounting;
+
+ALTER TABLE accounting.malicious_calls ADD COLUMN source varchar(255) after callee;
+
+SELECT id into @vpg_id FROM provisioning.voip_preference_groups where name = 'Internals';
+INSERT INTO provisioning.voip_preferences (voip_preference_groups_id, attribute, label, type, max_occur, usr_pref, prof_pref, dom_pref, peer_pref, contract_pref, modify_timestamp, internal, expose_to_customer, data_type, read_only, description)
+        VALUES
+(@vpg_id, 'identifier', "Identifier name", 0, 1, 0, 0, 1, 1, 0, NOW(), 0, 0, 'string', 0, 'Identifier name for a domain or a peer host (e.g. SIPWISE_1 or ACME_SBC). You can set it to any friendly name you prefer to identify this exchange point');
+
+commit;