# removing the mark that DB is updated from script
DELETE FROM conflines WHERE name = 'DB_Update_From_Script';
# DATA
UPDATE currencies SET name = 'ZMW' WHERE name = 'ZMK';
UPDATE conflines SET value = '25' WHERE value = '10' AND name = 'Backup_disk_space';
UPDATE conflines SET value = 150 WHERE name = 'mor_mapped_db_version';
INSERT IGNORE INTO conflines (name, value) SELECT 'mor_mapped_db_version', '150' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines where name = 'mor_mapped_db_version');
INSERT IGNORE INTO conflines (name, value) SELECT 'AST_18', '1' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines where name = 'AST_18');
update conflines set value = 0 where name = 'google_checkout_google_checkout_enabled';
INSERT IGNORE INTO conflines (name,value) SELECT 'Max_PDF_pages', 100 FROM DUAL WHERE (SELECT COUNT(*) FROM conflines WHERE name = 'Max_PDF_pages') = 0;
UPDATE conflines SET value = 'MOR X5' WHERE value = 'MOR X4';
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '247','<b>247 - Dead Provider skipped</b><br/>Provider used to terminate the call was disabled by MOR because it was unreachable.<br/>Functionality which disables provider can be disabled/enabled by option "Periodic check" in Provider settings, SIP Specific section.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '247');
UPDATE hangupcausecodes SET description='<b>247 - Dead Provider skipped</b><br/>Provider used to terminate the call was disabled by MOR because it was unreachable.<br/>Functionality which disables provider can be disabled/enabled by option "Periodic check" in Provider settings, SIP Specific section.' WHERE code = '247';
INSERT INTO conflines (name, value) SELECT 'Invoice_email_notice_admin', 1 FROM dual WHERE NOT EXISTS (SELECT * FROM conflines where name = 'Invoice_email_notice_admin' and owner_id = 0);
INSERT INTO conflines (name, value) SELECT 'Invoice_email_notice_manager', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM conflines where name = 'Invoice_email_notice_manager' and owner_id = 0);
INSERT INTO conflines (name, value) SELECT 'How_often_to_send_email_notice', 5 FROM dual WHERE NOT EXISTS (SELECT * FROM conflines where name = 'How_often_to_send_email_notice' and owner_id = 0);
INSERT INTO conflines (name, value) SELECT 'Hide_active_calls_longer_than', 2 FROM dual WHERE NOT EXISTS (SELECT * FROM conflines where name = 'Hide_active_calls_longer_than' and owner_id = 0);
UPDATE hangupcausecodes SET description = REPLACE(description, '<b>236 Callback ', '<b>236 - Callback ') WHERE code = 236;
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '300','300 - Not authenticated (accountcode = 0)' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '300');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '301','301 - Originator not found' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '301');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '302','302 - Global Call Limit reached' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '302');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '303','303 - Originator Capacity reached' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '303');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '304','304 - CPS Limit reached' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '304');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '305','305 - Source (CallerID) not accepted by regexp' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '305');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '306','306 - Originator Balance Limit reached (Balance Min)' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '306');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '307','307 - Originator Rate not found' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '307');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '308','308 - Dial Peer not found' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '308');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '309','309 - No Dial Peer is available by regexp' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '309');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '310','310 - Suitable Terminator not found' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '310');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '311','311 - User is blocked' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '311');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '312','312 - Caller cancelled the call (CANCEL)' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '312');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '313','313 - User call limit reached' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '313');
UPDATE translations SET active = 1 WHERE name = 'Czech';
INSERT INTO conflines (name, value) SELECT 'm2_version', '62' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'm2_version' and owner_id = 0);
UPDATE conflines SET value = '321' where name = 'm2_version' and owner_id = 0;
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT 'warning_balance_email_local', 'Low Balance Warning', NOW(), 1, 'User <%= full_name %> will run out of balance soon.\n\nCurrent balance: <%= balance %> EUR', 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = 'warning_balance_email_local');
UPDATE conflines SET value = 80 WHERE value = 50 AND name = 'GUI_HDD_utilisation' and owner_id = 0;
UPDATE conflines SET value = 0 WHERE value = 90 AND name = 'GUI_CPU_General_load' and owner_id = 0;
UPDATE conflines SET value = 0 WHERE value = 4 AND name = 'GUI_CPU_Loadstats' and owner_id = 0;
UPDATE conflines SET value = 0 WHERE value = 90 AND name = 'GUI_CPU_Ruby_process' and owner_id = 0;
UPDATE conflines SET value = 0 WHERE value = 90 AND name = 'GUI_CPU_asterisk_process' and owner_id = 0;
UPDATE conflines SET value = 80 WHERE value = 50 AND name = 'DB_HDD_utilisation' and owner_id = 0;
UPDATE conflines SET value = 0 WHERE value = 90 AND name = 'DB_CPU_General_load' and owner_id = 0;
UPDATE conflines SET value = 0 WHERE value = 4 AND name = 'DB_CPU_Loadstats' and owner_id = 0;
UPDATE conflines SET value = 0 WHERE value = 90 AND name = 'DB_CPU_MySQL_process' and owner_id = 0;
UPDATE conflines SET value = 0 WHERE value = 90 AND name = 'DB_CPU_asterisk_process' and owner_id = 0;
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT 'payment_confirmation', 'Payment confirmation', NOW(), 1, 'Hello <%= full_name %>\n\nYour payment of <%= payment_amount %> <%= payment_currency %> was added.\n\nYour current balance: <%= balance %> <%= user_currency %>\n\nThank you for your business.', 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = 'payment_confirmation');
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT 'warning_balance_email_local2', 'Warning on balance increase', NOW(), 1, 'User\'s <%= full_name %> balance reached <%= balance %> <%= user_currency %>', 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = 'warning_balance_email_local2');
UPDATE conflines SET value='/usr/local/m2/backups' WHERE name = 'Backup_Folder';
INSERT INTO conflines (name, value) SELECT 'Asterisk_Server_IP', '192.168.1.9' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines where name = 'Asterisk_Server_IP' and owner_id = 0);
INSERT INTO conflines (name, value) SELECT 'Device_Range_MIN', 10001 FROM dual WHERE NOT EXISTS (SELECT * FROM conflines where name = 'Device_Range_MIN' and owner_id = 0);
INSERT INTO conflines (name, value) SELECT 'Device_Range_MAX', 99999 FROM dual WHERE NOT EXISTS (SELECT * FROM conflines where name = 'Device_Range_MAX' and owner_id = 0);
UPDATE emails SET body = 'Balance: <%= balance %> <%= currency %>' WHERE name = 'warning_balance_email' AND body = 'Balance: <%=balance %>';
UPDATE emails SET body = 'User <%= full_name %> will run out of balance soon.\n\nCurrent balance: <%= balance %> <%= currency %>' WHERE name = 'warning_balance_email_local' AND body = 'User <%= full_name %> will run out of balance soon.\n\nCurrent balance: <%= balance %> EUR';
UPDATE manager_rights SET name = 'SECURITY_Alerts_Schedules' WHERE name = 'SECURITY_Schedules';
UPDATE manager_rights SET nice_name = 'SECURITY > Alerts > Schedules' WHERE nice_name = 'SECURITY > Schedules';
UPDATE manager_rights SET name = 'SECURITY_Alerts_Contacts' WHERE name = 'SECURITY_Contacts';
UPDATE manager_rights SET nice_name = 'SECURITY > Alerts > Contacts' WHERE nice_name = 'SECURITY > Contacts';
UPDATE manager_rights SET name = 'SECURITY_Alerts_Groups' WHERE name = 'SECURITY_Groups';
UPDATE manager_rights SET nice_name = 'SECURITY > Alerts > Groups' WHERE nice_name = 'SECURITY > Groups';
INSERT INTO manager_rights (name, nice_name) SELECT 'USERS_Users', 'USERS > Users' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'USERS_Users');
INSERT INTO manager_rights (name, nice_name) SELECT 'USERS_Connection_Points','USERS > Connection Points' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'USERS_Connection_Points');
INSERT INTO manager_rights (name, nice_name) SELECT 'BILLING_Tariffs', 'BILLING > Tariffs' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'BILLING_Tariffs');
INSERT INTO manager_rights (name, nice_name) SELECT 'BILLING_CDR_Import', 'BILLING > CDR > Import' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'BILLING_CDR_Import');
INSERT INTO manager_rights (name, nice_name) SELECT 'BILLING_CDR_Rerating', 'BILLING > CDR > Rerating' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'BILLING_CDR_Rerating');
INSERT INTO manager_rights (name, nice_name) SELECT 'ROUTING_Routing_Groups', 'ROUTING > Routing Groups' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'ROUTING_Routing_Groups');
INSERT INTO manager_rights (name, nice_name) SELECT 'ROUTING_Dial_Peers', 'ROUTING > Dial Peers' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'ROUTING_Dial_Peers');
INSERT INTO manager_rights (name, nice_name) SELECT 'ACCOUNTING_Financial_Status', 'ACCOUNTING > Financial Status' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'ACCOUNTING_Financial_Status');
INSERT INTO manager_rights (name, nice_name) SELECT 'ACCOUNTING_Payments', 'ACCOUNTING > Payments' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'ACCOUNTING_Payments');
INSERT INTO manager_rights (name, nice_name) SELECT 'ACCOUNTING_Customer_Invoices', 'ACCOUNTING > Customer Invoices'  FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'ACCOUNTING_Customer_Invoices');
INSERT INTO manager_rights (name, nice_name) SELECT 'ACCOUNTING_Balance_Report', 'ACCOUNTING > Balance Report'  FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'ACCOUNTING_Balance_Report');
INSERT INTO manager_rights (name, nice_name) SELECT 'SECURITY_Integrity_Check', 'SECURITY > Integrity Check'  FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'SECURITY_Integrity_Check');
INSERT INTO manager_rights (name, nice_name) SELECT 'SECURITY_Alerts', 'SECURITY > Alerts'  FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'SECURITY_Alerts');
INSERT INTO manager_rights (name, nice_name) SELECT 'SECURITY_Alerts_Contacts', 'SECURITY > Alerts > Contacts'  FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'SECURITY_Alerts_Contacts');
INSERT INTO manager_rights (name, nice_name) SELECT 'SECURITY_Alerts_Schedules', 'SECURITY > Alerts > Schedules' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'SECURITY_Alerts_Schedules');
INSERT INTO manager_rights (name, nice_name) SELECT 'SECURITY_Alerts_Groups', 'SECURITY > Alerts > Groups' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'SECURITY_Alerts_Groups');
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Calls_by_Clients', 'REPORTS > Calls by Clients' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Calls_by_Clients');
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Aggregates', 'REPORTS > Aggregates' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Aggregates');
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Calls_List', 'REPORTS > Calls List' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Calls_List');
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Calls_List_Archived_Calls', 'REPORTS > Calls List > Archived Calls' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Calls_List_Archived_Calls');
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Active_Calls', 'REPORTS > Active Calls' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Active_Calls');
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Hangup_Cause', 'REPORTS > Hangup Cause' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Hangup_Cause');
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Load_Stats', 'REPORTS > Load Stats' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Load_Stats');
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Action_log', 'REPORTS > Action log' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Action_log');
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Search', 'REPORTS > Search' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Search');
INSERT INTO manager_rights (name, nice_name) SELECT 'MAINTENANCE_Settings', 'MAINTENANCE > Settings' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'MAINTENANCE_Settings');
INSERT INTO manager_rights (name, nice_name) SELECT 'MAINTENANCE_Default_User', 'MAINTENANCE > Default User' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'MAINTENANCE_Default_User');
INSERT INTO manager_rights (name, nice_name) SELECT 'MAINTENANCE_Default_Device', 'MAINTENANCE > Default Device' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'MAINTENANCE_Default_Device');
INSERT INTO manager_rights (name, nice_name) SELECT 'MAINTENANCE_Currencies', 'MAINTENANCE > Currencies' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'MAINTENANCE_Currencies');
INSERT INTO manager_rights (name, nice_name) SELECT 'MAINTENANCE_Emails', 'MAINTENANCE > Emails' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'MAINTENANCE_Emails');
INSERT INTO manager_rights (name, nice_name) SELECT 'MAINTENANCE_Backups', 'MAINTENANCE > Backups' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'MAINTENANCE_Backups');
INSERT INTO manager_rights (name, nice_name) SELECT 'MAINTENANCE_Background_Tasks', 'MAINTENANCE > Background Tasks' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'MAINTENANCE_Background_Tasks');
INSERT INTO manager_rights (name, nice_name) SELECT 'MAINTENANCE_Servers', 'MAINTENANCE > Servers' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'MAINTENANCE_Servers');
INSERT INTO manager_rights (name, nice_name) SELECT 'MAINTENANCE_Number_Pools', 'MAINTENANCE > Number Pools' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'MAINTENANCE_Number_Pools');
UPDATE rates JOIN destinations ON destinations.id = rates.destination_id SET rates.prefix = destinations.prefix WHERE rates.prefix = '';
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_number', 'D2' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_number');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_issue_date', 'H2' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_issue_date');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_period_start', 'G6' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_period_start');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_period_end', 'H6' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_period_end');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_client_name', 'G5' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_client_name');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_due_date', 'F5' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_due_date');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_client_details1', 'F6' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_client_details1');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_client_details2', 'G7' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_client_details2');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_client_details3', 'G8' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_client_details3');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_client_details4', 'G9' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_client_details4');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_client_details5', 'G10' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_client_details5');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_client_details6', 'G11' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_client_details6');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_lines_destination', 'B13' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_lines_destination');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_lines_name', 'F13' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_lines_name');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_lines_calls', 'I13' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_lines_calls');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_lines_nice_total_time', 'H13' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_lines_nice_total_time');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_lines_nice_price', 'J13' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_lines_nice_price');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_lines_destination_number', 'A13' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_lines_destination_number');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_nice_total_amount', 'A4' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_nice_total_amount');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_nice_total_amount_with_tax', 'A5' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_nice_total_amount_with_tax');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_exchange_rate', 'A3' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_exchange_rate');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_comment', 'A2' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_comment');
INSERT INTO conflines (name, value) SELECT 'Cell_m2_invoice_timezone', 'A1' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Cell_m2_invoice_timezone');
#DELETE FROM conflines WHERE name = 'Cell_m2_invoice_lines_rate';
DELETE FROM conflines WHERE name = 'Default_device_qualify_time';
UPDATE hangupcausecodes SET description = "<b>301 - Originator not found by IP</b>" WHERE code = "301";
DELETE FROM emails WHERE name IN ("registration_confirmation_for_user", "registration_confirmation_for_admin");
INSERT INTO manager_rights (name, nice_name) SELECT 'MAINTENANCE_Directions', 'MAINTENANCE > Directions' FROM dual where NOT EXISTS (SELECT * FROM manager_rights where name = 'MAINTENANCE_Directions');
INSERT INTO manager_rights (name, nice_name) SELECT 'MAINTENANCE_Directions_Groups', 'MAINTENANCE > Directions > Groups' FROM dual where NOT EXISTS (SELECT * FROM manager_rights where name = 'MAINTENANCE_Directions_Groups');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '314','314 - M2 radius server did not receive accounting start packet (acct start timeout)' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '314');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '315','315 - M2 radius server did not receive accounting stop packet (acct stop timeout)' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '315');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '316','316 - Freeswitch did not find termination point details' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '316');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '317','317 - Registration to termination point failed' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '317');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '318','318 - Originator codecs are not allowed' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '318');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '319','319 - M2 can not make more calls' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '319');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '320','320 - Balance too low to make a call' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '320');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '321',"321 - Caller source number (CallerID) does not match Terminator source regexp" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '321');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '322',"322 - Caller source number (CallerID) is denied by Terminator source deny regexp" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '322');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '323',"323 - Terminator balance limit reached (balance max)" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '323');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '324',"324 - Rate margin is lower than allowed" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '324');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '325','325 - Destination is in blacklist' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '325');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '326','326 - Destination is not in whitelist' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '326');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '327','327 - Terminator capacity reached' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '327');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '328','328 - Terminator user call limit reached' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '328');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '329','329 - Terminator CPS limit reached' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '329');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '330',"330 - Destination is blocked in Originator Tariff" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '330');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '331',"331 - Destination is blocked in Terminator Tariff" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '331');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '332',"332 - Originator tech prefix does not match destination number" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '332');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '333',"333 - Originator port is not allowed" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '333');
DELETE `confl1` FROM `conflines` `confl1`, `conflines` `confl2` WHERE `confl1`.`id` > `confl2`.`id` AND `confl1`.`name` = `confl2`.`name` AND `confl1`.`owner_id` = `confl2`.`owner_id` AND `confl1`.`name` LIKE 'Cell_m2_inv%';
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '334','334 - Source number is in blacklist' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '334');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '335','335 - Source number is not in whitelist' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '335');
DELETE FROM m2_invoice_lines WHERE NOT EXISTS (SELECT NULL FROM m2_invoices WHERE m2_invoices.id = m2_invoice_lines.m2_invoice_id);
DELETE FROM manager_rights WHERE name = 'REPORTS_Call_Tracing';
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '336','336 - Destination can not be empty' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '336');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '337','337 - Call comes from servers which is not assigned to originator' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '337');
INSERT INTO manager_rights (name, nice_name) SELECT 'BILLING_Custom_Tariffs', 'BILLING > Custom Tariffs' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'BILLING_Custom_Tariffs');
UPDATE hangupcausecodes SET description = '<b>16 - Normal call clearing</b>' WHERE code = 16;
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '338','338 - Unreachable Terminator skipped (Periodic Check is enabled)' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '338');
INSERT INTO manager_rights (name, nice_name) SELECT 'SECURITY_Blocked_IPs', 'SECURITY > Blocked IPs' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'SECURITY_Blocked_IPs');
DELETE FROM emails WHERE name = 'c2c_invoices';
DELETE FROM emails WHERE name = 'monitoring_activation';
DELETE FROM emails WHERE name = 'cyberplat_announce';
DELETE FROM emails WHERE name = 'calling_cards_data_to_paypal';
DELETE FROM emails WHERE name = 'recording_new';
DELETE FROM emails WHERE name = 'recording_delete';
DELETE FROM emails WHERE name = 'payment_notification_integrations';
DELETE FROM emails WHERE name = 'payment_notification_regular';
DELETE FROM emails WHERE name = 'callerid_blocked';
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '339','339 - User is not allowed to dial through own terminators' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '339');
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT 'server_low_free_space', 'Server low free space', NOW(), 1, 'Server free space limit exceeded, please investigate.<br/><br/>Server: ID: <%= server_id %>; IP: <%= server_ip %><br/>Free Space: <%= hdd_free_space %>%', 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = 'server_low_free_space');
UPDATE emails SET body = 'Server free space limit exceeded, please investigate.<br/><br/>Server: ID: <%= server_id %>; IP: <%= server_ip %><br/>Free Space: <%= hdd_free_space %>%' WHERE name = 'server_low_free_space';
UPDATE emails SET subject = 'Low Disk Space Alert' WHERE name = 'server_low_free_space';
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Destination_Groups', 'REPORTS > Destination Groups' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Destination_Groups');
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT 'cdr_export_success', 'CDR Export', NOW(), 1, 'CDR archive is attached', 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = 'cdr_export_success');
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT 'cdr_export_error', 'CDR Export error', NOW(), 1, 'Size of CDR archive is too big and can not be downloaded', 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = 'cdr_export_error');
DELETE FROM hangupcausecodes WHERE code BETWEEN 200 AND 299;
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Calls_Dashboard', 'REPORTS > Calls Dashboard' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Calls_Dashboard');
DELETE FROM codecs WHERE codec_type != 'audio';
DELETE FROM codecs WHERE name IN ('adpcm', 'slin', 'ilbc');
INSERT INTO codecs (name, long_name, codec_type) SELECT 'g722', 'G.722', 'audio' FROM dual WHERE NOT EXISTS (SELECT * FROM codecs WHERE name = 'g722');
INSERT INTO conflines (name, value) SELECT 'Default_device_codec_g722', '0' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Default_device_codec_g722');
INSERT INTO iplocations (ip, approved, uniquehash) SELECT '77.240.248.90', 1, 'kolmisoft' FROM dual WHERE NOT EXISTS (SELECT * FROM iplocations WHERE ip = '77.240.248.90');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '340', "<b>340 - User call rate is higher than allowed</b>" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '340');
UPDATE servers SET ssh_secret = NULL;
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_TP_Deviations', 'REPORTS > TP Deviations' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_TP_Deviations');
DELETE FROM codecs WHERE name = 'lpc10';
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Calls_Per_Hour', 'REPORTS > Calls Per Hour' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Calls_Per_Hour');
INSERT INTO manager_rights (name, nice_name) SELECT 'DASHBOARD_Quick_Stats', 'DASHBOARD > Quick Stats' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'DASHBOARD_Quick_Stats');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '607','607 - Progress Timeout' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '607');
UPDATE directions SET name = REPLACE(LOWER(name), 'ivory cost', 'Ivory Coast') WHERE name LIKE '%Ivory Cost%';
UPDATE destinations SET name = REPLACE(LOWER(name), 'ivory cost', 'Ivory Coast') WHERE name LIKE '%Ivory Cost%';
UPDATE destinationgroups SET name = REPLACE(LOWER(name), 'ivory cost', 'Ivory Coast') WHERE name LIKE '%Ivory Cost%';
UPDATE directions SET name = REPLACE(LOWER(name), 'viet nam', 'Vietnam') WHERE name LIKE '%Viet Nam%';
UPDATE destinations SET name = REPLACE(LOWER(name), 'viet nam', 'Vietnam') WHERE name LIKE '%Viet Nam%';
UPDATE destinationgroups SET name = REPLACE(LOWER(name), 'viet nam', 'Vietnam') WHERE name LIKE '%Viet Nam%';
INSERT IGNORE INTO number_pools (name) SELECT 'EEA' FROM dual WHERE NOT EXISTS (SELECT * FROM number_pools WHERE name = 'EEA');
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '43%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '43%'  AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '32%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '32%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '359%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '359%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '385%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '385%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '357%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '357%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '420%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '420%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '45%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '45%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '372%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '372%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '358%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '358%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '33%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '33%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '350%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '350%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '49%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '49%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '30%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '30%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '36%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '36%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '354%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '354%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '353%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '353%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '39%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '39%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '371%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '371%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '423%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '423%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '370%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '370%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '352%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '352%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '356%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '356%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '31%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '31%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '47%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '47%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '48%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '48%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '351%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '351%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '40%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '40%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '421%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '421%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '386%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '386%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '34%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '34%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '46%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '46%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO numbers (number, number_pool_id) SELECT '44%', (SELECT id FROM number_pools WHERE name = 'EEA') FROM dual WHERE NOT EXISTS (SELECT * FROM numbers WHERE number = '44%' AND number_pool_id = (SELECT id FROM number_pools WHERE name = 'EEA'));
INSERT IGNORE INTO conflines (name, value) SELECT 'Delete_Archived_Calls_older_than', '0' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'Delete_Archived_Calls_older_than');
INSERT IGNORE INTO conflines (name, value) SELECT 'ftp_port', '21' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'ftp_port');
INSERT IGNORE INTO conflines (name, value) SELECT 'ftp_archived_calls_path', '/' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'ftp_archived_calls_path');
INSERT IGNORE INTO conflines (name, value) SELECT 'ftp_backups_path', '/' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'ftp_backups_path');
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Aggregate_Templates', 'REPORTS > Aggregate Templates' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Aggregate_Templates');
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT 'auto_aggregate_report', 'Aggregate Report', NOW(), 1, 'Aggregate Report in attached CSV file', 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = 'auto_aggregate_report');
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Aggregate_Auto_Export', 'REPORTS > Aggregate Auto Export' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Aggregate_Auto_Export');
INSERT IGNORE INTO `aggregate_templates` (`answered_calls`, `duration_show`, `from_user_perspective`, `group_by_dst`, `group_by_originator`, `group_by_terminator`, `name`, `profit_show`, `s_originator_id`, `s_terminator`, `s_terminator_id`, `use_real_billsec`, `user_id`) SELECT '1', 1, 0, 1, 1, 1, 'Profit/Duration by Prefix', 1, -1, '', -1, 0, 0 FROM dual WHERE NOT EXISTS (SELECT * FROM aggregate_templates WHERE name NOT IN ('Originator Info', 'Terminator Info'));
INSERT IGNORE INTO `aggregate_templates` (`acd_show`, `answered_calls`, `asr_show`, `calls_answered_show`, `calls_total_show`, `duration_show`, `from_user_perspective`, `group_by_originator`, `name`, `pdd_show`, `price_orig_show`, `profit_show`, `s_originator_id`, `s_terminator`, `s_terminator_id`, `use_real_billsec`, `user_id`) SELECT 1, '0', 1, 1, 1, 1, 0, 1, 'Originator Info', 1, 1, 1, -1, '', -1, 0, 0 FROM dual WHERE NOT EXISTS (SELECT * FROM aggregate_templates WHERE name NOT IN ('Profit/Duration by Prefix', 'Terminator Info'));
INSERT IGNORE INTO `aggregate_templates` (`acd_show`, `answered_calls`, `asr_show`, `calls_answered_show`, `calls_total_show`, `duration_show`, `from_user_perspective`, `group_by_terminator`, `name`, `pdd_show`, `price_term_show`, `profit_show`, `s_originator_id`, `s_terminator`, `s_terminator_id`, `use_real_billsec`, `user_id`) SELECT 1, '0', 1, 1, 1, 1, 0, 1, 'Terminator Info', 1, 1, 1, -1, '', -1, 0, 0 FROM dual WHERE NOT EXISTS (SELECT * FROM aggregate_templates WHERE name NOT IN ('Profit/Duration by Prefix', 'Originator Info'));
INSERT IGNORE INTO emails (name, body, subject, date_created, template) SELECT 'send_warning_balance_sms', 'Low balance: <%= full_name%> / <%= balance %> <%= currency%>', 'Low Balance Warning SMS', NOW(), 1 FROM dual WHERE NOT EXISTS (SELECT name FROM emails WHERE name = 'send_warning_balance_sms');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '341', "<b>341 - Originator's IP is unknown</b>" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '341');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '342', "<b>342 - Global Incoming System CPS limit reached</b>" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '342');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '343', "<b>343 - Too many hops</b>" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '343');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '344', "<b>344 - Terminator reached call limit in a Dial Peer</b>" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '344');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '345', "<b>345 - Terminator reached CPS limit in a Dial Peer</b>" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '345');
INSERT INTO tariff_templates (name, rate_sheet, header_lines, prefix_column, prefix_column2, destination_column, first_interval_rate_column, effective_date_option, effective_date_column, effective_date_option_secondary, generated_template) SELECT 'Pre-Made HGC', 1, 20, 'B', 'C', 'A', 'F', 0, 'G', 0, '# export file settings\\nexport_column_separator=,\\nexport_decimal_separator=.\\ndate_format=YYYY-MM-DD\\nexported_columns=prefix,destination,first_interval_rate,effective_date\\nprefix_name=Prefix\\ndestination_name=Destination\\nconnection_fee_name=Connection Fee\\nfirst_interval_rate_name=Rate\\nfirst_interval_increment_name=Increment\\nfirst_interval_mintime_name=Min. time\\nsecond_interval_rate_name=Second Interval Rate\\nsecond_interval_increment_name=Second Interval Increment\\nsecond_interval_mintime_name=Second Interval Min. time\\noff_peak_first_interval_rate_name=Off-Peak First Interval Rate\\noff_peak_first_interval_increment_name=Off-Peak First Interval Increment\\noff_peak_first_interval_mintime_name=Off-Peak First Interval Min. time\\noff_peak_second_interval_rate_name=Off-Peak Second Interval Rate\\noff_peak_second_interval_increment_name=Off-Peak Second Interval Increment\\noff_peak_second_interval_mintime_name=Off-Peak Second Interval Min. time\\neffective_date_name=Effective from\\nend_date_name=End Date\\n# which sheet to use for data\\nrate_sheet=1\\n# how many header lines to skip\\nheader_lines=20\\n# column-row mapping\\nprefix_column=B+C\\ndestination_column=A\\nconnection_fee_column=\\nfirst_interval_rate_column=F\\nfirst_interval_increment_column=\\nfirst_interval_mintime_column=\\nsecond_interval_rate_column=\\nsecond_interval_increment_column=\\nsecond_interval_mintime_column=\\noff_peak_first_interval_rate_column=\\noff_peak_first_interval_increment_column=\\noff_peak_first_interval_mintime_column=\\noff_peak_second_interval_rate_column=\\noff_peak_second_interval_increment_column=\\noff_peak_second_interval_mintime_column=\\neffective_date_column=G\\nend_date_column=\\nprefix_column_secondary=\\ndestination_column_secondary=\\nconnection_fee_column_secondary=\\nfirst_interval_rate_column_secondary=\\nfirst_interval_increment_column_secondary=\\nfirst_interval_mintime_column_secondary=\\nsecond_interval_rate_column_secondary=\\nsecond_interval_increment_column_secondary=\\nsecond_interval_mintime_column_secondary=\\noff_peak_first_interval_rate_column_secondary=\\noff_peak_first_interval_increment_column_secondary=\\noff_peak_first_interval_mintime_column_secondary=\\noff_peak_second_interval_rate_column_secondary=\\noff_peak_second_interval_increment_column_secondary=\\noff_peak_second_interval_mintime_column_secondary=\\neffective_date_column_secondary=\\nend_date_column_secondary=\\n#effective_date_column_format=\\n# data manipulation\\n# new_rate_column' FROM DUAL WHERE NOT EXISTS (SELECT name FROM tariff_templates WHERE name = 'Pre-Made HGC');
INSERT INTO tariff_templates (name, rate_sheet, header_lines, prefix_column, prefix_column2, destination_column, destination_column2, first_interval_rate_column, effective_date_option, effective_date_column, effective_date_format, effective_date_option_secondary, generated_template) SELECT 'Pre-Made TATA', 1, 22, 'C', 'D', 'A', 'B', 'E', 0, 'F', '%d-%b-%Y', 0, '# export file settings\\nexport_column_separator=,\\nexport_decimal_separator=.\\ndate_format=YYYY-MM-DD\\nexported_columns=prefix,destination,first_interval_rate,effective_date\\nprefix_name=Prefix\\ndestination_name=Destination\\nconnection_fee_name=Connection Fee\\nfirst_interval_rate_name=Rate\\nfirst_interval_increment_name=Increment\\nfirst_interval_mintime_name=Min. time\\nsecond_interval_rate_name=Second Interval Rate\\nsecond_interval_increment_name=Second Interval Increment\\nsecond_interval_mintime_name=Second Interval Min. time\\noff_peak_first_interval_rate_name=Off-Peak First Interval Rate\\noff_peak_first_interval_increment_name=Off-Peak First Interval Increment\\noff_peak_first_interval_mintime_name=Off-Peak First Interval Min. time\\noff_peak_second_interval_rate_name=Off-Peak Second Interval Rate\\noff_peak_second_interval_increment_name=Off-Peak Second Interval Increment\\noff_peak_second_interval_mintime_name=Off-Peak Second Interval Min. time\\neffective_date_name=Effective from\\nend_date_name=End Date\\n# which sheet to use for data\\nrate_sheet=1\\n# how many header lines to skip\\nheader_lines=22\\n# column-row mapping\\nprefix_column=C+D\\ndestination_column=A+B\\nconnection_fee_column=\\nfirst_interval_rate_column=E\\nfirst_interval_increment_column=\\nfirst_interval_mintime_column=\\nsecond_interval_rate_column=\\nsecond_interval_increment_column=\\nsecond_interval_mintime_column=\\noff_peak_first_interval_rate_column=\\noff_peak_first_interval_increment_column=\\noff_peak_first_interval_mintime_column=\\noff_peak_second_interval_rate_column=\\noff_peak_second_interval_increment_column=\\noff_peak_second_interval_mintime_column=\\neffective_date_column=F\\nend_date_column=\\nprefix_column_secondary=\\ndestination_column_secondary=\\nconnection_fee_column_secondary=\\nfirst_interval_rate_column_secondary=\\nfirst_interval_increment_column_secondary=\\nfirst_interval_mintime_column_secondary=\\nsecond_interval_rate_column_secondary=\\nsecond_interval_increment_column_secondary=\\nsecond_interval_mintime_column_secondary=\\noff_peak_first_interval_rate_column_secondary=\\noff_peak_first_interval_increment_column_secondary=\\noff_peak_first_interval_mintime_column_secondary=\\noff_peak_second_interval_rate_column_secondary=\\noff_peak_second_interval_increment_column_secondary=\\noff_peak_second_interval_mintime_column_secondary=\\neffective_date_column_secondary=\\nend_date_column_secondary=\\neffective_date_column_format=%d-%b-%Y\\n# data manipulation\\n# new_rate_column' FROM DUAL WHERE NOT EXISTS (SELECT name FROM tariff_templates WHERE name = 'Pre-Made TATA');
INSERT INTO tariff_templates (name, rate_sheet, header_lines, prefix_column, destination_column, first_interval_rate_column, effective_date_option, effective_date_mapping_sheet, effective_date_mapping_datetime, effective_date_mapping_column_sheet, effective_date_mapping_column_main, effective_date_format, prefix_column_secondary, destination_column_secondary, first_interval_rate_column_secondary, effective_date_option_secondary, effective_date_mapping_sheet_secondary, effective_date_mapping_datetime_secondary, effective_date_mapping_column_sheet_secondary, effective_date_mapping_column_main_secondary, generated_template) SELECT 'Pre-Made Voicetrading', 2, 0, 'B', 'A', 'C', 1, 1, 'D', 'A', 'A', '%Y.%m.%d', 'F', 'E', 'G', 1, 1, 'D', 'A', 'E', '# export file settings\\nexport_column_separator=,\\nexport_decimal_separator=.\\ndate_format=YYYY-MM-DD\\nexported_columns=prefix,destination,first_interval_rate,effective_date\\nprefix_name=Prefix\\ndestination_name=Destination\\nconnection_fee_name=Connection Fee\\nfirst_interval_rate_name=Rate\\nfirst_interval_increment_name=Increment\\nfirst_interval_mintime_name=Min. time\\nsecond_interval_rate_name=Second Interval Rate\\nsecond_interval_increment_name=Second Interval Increment\\nsecond_interval_mintime_name=Second Interval Min. time\\noff_peak_first_interval_rate_name=Off-Peak First Interval Rate\\noff_peak_first_interval_increment_name=Off-Peak First Interval Increment\\noff_peak_first_interval_mintime_name=Off-Peak First Interval Min. time\\noff_peak_second_interval_rate_name=Off-Peak Second Interval Rate\\noff_peak_second_interval_increment_name=Off-Peak Second Interval Increment\\noff_peak_second_interval_mintime_name=Off-Peak Second Interval Min. time\\neffective_date_name=Effective from\\nend_date_name=End Date\\n# which sheet to use for data\\nrate_sheet=2\\n# how many header lines to skip\\nheader_lines=0\\n# column-row mapping\\nprefix_column=B\\ndestination_column=A\\nconnection_fee_column=\\nfirst_interval_rate_column=C\\nfirst_interval_increment_column=\\nfirst_interval_mintime_column=\\nsecond_interval_rate_column=\\nsecond_interval_increment_column=\\nsecond_interval_mintime_column=\\noff_peak_first_interval_rate_column=\\noff_peak_first_interval_increment_column=\\noff_peak_first_interval_mintime_column=\\noff_peak_second_interval_rate_column=\\noff_peak_second_interval_increment_column=\\noff_peak_second_interval_mintime_column=\\neffective_date_column=1|D|A|A\\nend_date_column=\\nprefix_column_secondary=F\\ndestination_column_secondary=E\\nconnection_fee_column_secondary=\\nfirst_interval_rate_column_secondary=G\\nfirst_interval_increment_column_secondary=\\nfirst_interval_mintime_column_secondary=\\nsecond_interval_rate_column_secondary=\\nsecond_interval_increment_column_secondary=\\nsecond_interval_mintime_column_secondary=\\noff_peak_first_interval_rate_column_secondary=\\noff_peak_first_interval_increment_column_secondary=\\noff_peak_first_interval_mintime_column_secondary=\\noff_peak_second_interval_rate_column_secondary=\\noff_peak_second_interval_increment_column_secondary=\\noff_peak_second_interval_mintime_column_secondary=\\neffective_date_column_secondary=1|D|A|E\\nend_date_column_secondary=\\neffective_date_column_format=%Y.%m.%d\\n# data manipulation\\n# new_rate_column' FROM DUAL WHERE NOT EXISTS (SELECT name FROM tariff_templates WHERE name = 'Pre-Made Voicetrading');
INSERT IGNORE INTO emails (name, body, subject, date_created, template) SELECT 'tariff_rate_notification', "Dear Partner,<br/><br/>Please review attached Tariff's Rate changes.<br/><br/>To confirm upcoming rate changes, please click the link below:<br/><br/><%= rate_notification_url_agree %><br/><br/>If You do not agree with the changes, please click the link below:<br/><br/><%= rate_notification_url_disagree %><br/><br/>Thank you for cooperation.", 'Tariff Rate Notification', NOW(), 1 FROM dual WHERE NOT EXISTS (SELECT name FROM emails WHERE name = 'tariff_rate_notification');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '346', "<b>346 - Call terminated by hangup command</b>" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '346');
INSERT IGNORE INTO `aggregate_templates` (`answered_calls`, `billed_time_orig_show`, `calls_answered_show`, `calls_total_show`, `from_user_perspective`, `group_by_manager`, `name`, `price_orig_show`, `price_term_show`, `profit_percent_show`, `profit_show`, `s_originator_id`, `s_terminator`, `s_terminator_id`, `use_real_billsec`, `user_id`, `duration_show`) SELECT '1', 1, 1, 1, 0, 1, 'Account Manager Revenue and Profit', 1, 1, 1, 1, -1, '', -1, 0, 0, 1 FROM dual WHERE NOT EXISTS (SELECT * FROM aggregate_templates WHERE name = 'Account Manager Revenue and Profit');
INSERT INTO manager_rights (name, nice_name) SELECT 'Show_only_assigned_Users', 'Show only assigned Users' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'Show_only_assigned_Users');
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Calls_List_Hide_Vendors_Rate', "REPORTS > Calls List | Hide Vendor's Rate" FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Calls_List_Hide_Vendors_Rate');
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Calls_List_Hide_Vendors_Price', "REPORTS > Calls List | Hide Vendor's Price" FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Calls_List_Hide_Vendors_Price');
INSERT INTO manager_rights (name, nice_name) SELECT 'USERS_Connection_Points_Deny_Tariff_change', 'USERS > Connection Points | Deny Tariff change' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'USERS_Connection_Points_Deny_Tariff_change');
INSERT INTO manager_rights (name, nice_name) SELECT 'USERS_Connection_Points_Deny_Routing_Group_change', 'USERS > Connection Points | Deny Routing Group change' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'USERS_Connection_Points_Deny_Routing_Group_change');
INSERT INTO manager_rights (name, nice_name) SELECT 'REPORTS_Active_Calls_Hide_Vendors_Information', "REPORTS > Active Calls | Hide Vendor's Information"  FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'REPORTS_Active_Calls_Hide_Vendors_Information');
INSERT INTO manager_rights (name, nice_name) SELECT 'BILLING_Tariffs_Vendors_Tariffs', "BILLING > Tariffs | Vendor's Tariffs"  FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'BILLING_Tariffs_Vendors_Tariffs');
INSERT INTO manager_rights (name, nice_name) SELECT 'BILLING_Tariffs_Users_Tariffs', "BILLING > Tariffs | User's Tariffs"  FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'BILLING_Tariffs_Users_Tariffs');
UPDATE numbers SET pattern = IF((INSTR(`number`, '%') OR INSTR(`number`, '_')), 1, 0) WHERE pattern IS NULL;
UPDATE manager_rights SET nice_name = 'USERS > Connection Points Edit' WHERE name = 'USERS_Connection_Points';
UPDATE IGNORE manager_rights SET name = 'USERS_Connection_Points_Edit' WHERE name = 'USERS_Connection_Points';
INSERT INTO manager_rights (name, nice_name) SELECT 'USERS_Connection_Points_List','USERS > Connection Points List' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'USERS_Connection_Points_List');
INSERT INTO manager_rights (name, nice_name) SELECT 'Call_Tracing','Call Tracing' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'Call_Tracing');
INSERT INTO manager_rights (name, nice_name) SELECT 'BILLING_Tariffs_Rate_Notifications','BILLING > Tariffs > Rate Notifications' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'BILLING_Tariffs_Rate_Notifications');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '347', "<b>347 - Duplicate CallID/UniqueID</b>" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '347');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '400','<b>400 - Bad Request</b><br/>The request could not be understood due to malformed syntax.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '400');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '401','<b>401 - Unauthorized</b><br/>The request requires user authentication. This response is issued by UASs and registrars.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '401');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '402','<b>402 - Payment Required</b><br/>Reserved for future use.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '402');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '403','<b>403 - Forbidden</b><br/>The server understood the request, but is refusing to fulfill it. Sometimes (but not always) this means the call has been rejected by the receiver.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '403');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '404','<b>404 - Not Found</b><br/>The server has definitive information that the user does not exist at the domain specified in the Request-URI. This status is also returned if the domain in the Request-URI does not match any of the domains handled by the recipient of the request.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '404');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '405','<b>405 - Method Not Allowed</b><br/>The method specified in the Request-Line is understood, but not allowed for the address identified by the Request-URI.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '405');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '406','<b>406 - Not Acceptable</b><br/>The resource identified by the request is only capable of generating response entities that have content characteristics but not acceptable according to the Accept header field sent in the request.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '406');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '407','<b>407 - Proxy Authentication Required</b><br/>The request requires user authentication. This response is issued by proxys.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '407');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '408',"<b>408 - Request Timeout</b><br/>Couldn't find the user in time. The server could not produce a response within a suitable amount of time, for example, if it could not determine the location of the user in time. The client MAY repeat the request without modifications at any later time." FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '408');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '409','<b>409 - Conflict</b><br/>User already registered. Deprecated by omission from later RFCs and by non-registration with the IANA.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '409');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '410','<b>410 - Gone</b><br/>The user existed once, but is not available here any more.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '410');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '411','<b>411 - Length Required</b><br/>The server will not accept the request without a valid Content-Length. Deprecated by omission from later RFCs and by non-registration with the IANA.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '411');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '412','<b>412 - Conditional Request Failed</b><br/>The given precondition has not been met.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '412');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '413','<b>413 - Request Entity Too Large</b><br/>Request body too large.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '413');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '414','<b>414 - Request-URI Too Long</b><br/>The server is refusing to service the request because the Request-URI is longer than the server is willing to interpret.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '414');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '415','<b>415 - Unsupported Media Type</b><br/>Request body in a format not supported.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '415');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '416','<b>416 - Unsupported URI Scheme</b><br/>Request-URI is unknown to the server.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '416');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '417','<b>417 - Unknown Resource-Priority</b><br/>There was a resource-priority option tag, but no Resource-Priority header.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '417');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '420','<b>420 - Bad Extension</b><br/>Bad SIP Protocol Extension used, not understood by the server.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '420');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '421','<b>421 - Extension Required</b><br/>The server needs a specific extension not listed in the Supported header.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '421');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '422','<b>422 - Session Interval Too Small</b><br/>The received request contains a Session-Expires header field with a duration below the minimum timer.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '422');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '423','<b>423 - Interval Too Brief</b><br/>Expiration time of the resource is too short.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '423');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '424',"<b>424 - Bad Location Information</b><br/>The request's location content was malformed or otherwise unsatisfactory." FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '424');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '425','<b>425 - Bad Alert Message</b><br/>The server rejected a non-interactive emergency call, indicating that the request was malformed enough that no reasonable emergency response to the alert can be determined.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '425');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '428','<b>428 - Use Identity Header</b><br/>The server policy requires an Identity header, and one has not been provided.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '428');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '429','<b>429 - Provide Referrer Identity</b><br/>The server did not receive a valid Referred-By token on the request.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '429');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '430','<b>430 - Flow Failed</b><br/>A specific flow to a user agent has failed, although other flows may succeed. This response is intended for use between proxy devices, and should not be seen by an endpoint (and if it is seen by one, should be treated as a 400 Bad Request response).' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '430');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '433','<b>433 - Anonymity Disallowed</b><br/>The request has been rejected because it was anonymous.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '433');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '436','<b>436 - Bad Identity-Info</b><br/>The request has an Identity-Info header, and the URI scheme in that header cannot be dereferenced.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '436');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '437','<b>437 - Unsupported Certificate</b><br/>The server was unable to validate a certificate for the domain that signed the request.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '437');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '438','<b>438 - Invalid Identity Header</b><br/>The server obtained a valid certificate that the request claimed was used to sign the request, but was unable to verify that signature.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '438');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '439','<b>439 - First Hop Lacks Outbound Support</b><br/>The first outbound proxy the user is attempting to register through does not support the "outbound" feature of RFC 5626, although the registrar does.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '439');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '440','<b>440 - Max-Breadth Exceeded</b><br/>If a SIP proxy determines a response context has insufficient Incoming Max-Breadth to carry out a desired parallel fork, and the proxy is unwilling/unable to compensate by forking serially or sending a redirect, that proxy MUST return a 440 response. A client receiving a 440 response can infer that its request did not reach all possible destinations.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '440');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '469','<b>469 - Bad Info Package</b><br/>If a SIP UA receives an INFO request associated with an Info Package that the UA has not indicated willingness to receive, the UA MUST send a 469 response, which contains a Recv-Info header field with Info Packages for which the UA is willing to receive INFO requests.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '469');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '470','<b>470 - Consent Needed</b><br/>The source of the request did not have the permission of the recipient to make such a request.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '470');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '480','<b>480 - Temporarily Unavailable</b><br/>Callee currently unavailable.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '480');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '481','<b>481 - Call/Transaction Does Not Exist</b><br/>Server received a request that does not match any dialog or transaction.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '481');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '482','<b>482 - Loop Detected</b><br/>Server has detected a loop.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '482');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '483',"<b>483 - Too Many Hops</b><br/>Max-Forwards header has reached the value '0'." FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '483');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '484','<b>484 - Address Incomplete</b><br/>Request-URI incomplete.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '484');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '485','<b>485 - Ambiguous</b><br/>Request-URI is ambiguous.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '485');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '486','<b>486 - Busy Here</b><br/>Callee is busy.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '486');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '487','<b>487 - Request Terminated</b><br/>Request has terminated by bye or cancel.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '487');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '488','<b>488 - Not Acceptable Here</b><br/>Some aspect of the session description or the Request-URI is not acceptable.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '488');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '489','<b>489 - Bad Event</b><br/>The server did not understand an event package specified in an Event header field.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '489');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '491','<b>491 - Request Pending</b><br/>Server has some pending request from the same dialog.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '491');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '493','<b>493 - Undecipherable</b><br/>Request contains an encrypted MIME body, which recipient can not decrypt.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '493');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '494','<b>494 - Security Agreement Required</b><br/>The server has received a request that requires a negotiated security mechanism, and the response contains a list of suitable security mechanisms for the requester to choose between, or a digest authentication challenge.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '494');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '500','<b>500 - Internal Server Error</b><br/>The server could not fulfill the request due to some unexpected condition.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '500');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '501','<b>501 - Not Implemented</b><br/>The server does not have the ability to fulfill the request, such as because it does not recognize the request method. (Compare with 405 Method Not Allowed, where the server recognizes the method but does not allow or support it.)' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '501');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '502','<b>502 - Bad Gateway</b><br/>The server is acting as a gateway or proxy, and received an invalid response from a downstream server while attempting to fulfill the request.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '502');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '503','<b>503 - Service Unavailable</b><br/>The server is undergoing maintenance or is temporarily overloaded and so cannot process the request. A "Retry-After" header field may specify when the client may reattempt its request.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '503');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '504','<b>504 - Server Time-out</b><br/>The server attempted to access another server in attempting to process the request, and did not receive a prompt response.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '504');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '505','<b>505 - Version Not Supported</b><br/>The SIP protocol version in the request is not supported by the server.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '505');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '513','<b>513 - Message Too Large</b><br/>The request message length is longer than the server can process.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '513');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '555',"<b>555 - Push Notification Service Not Supported</b><br/>The server does not support the push notification service identified in a 'pn-provider' SIP URI parameter." FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '555');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '580','<b>580 - Precondition Failure</b><br/>The server is unable or unwilling to meet some constraints specified in the offer.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '580');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '600','<b>600 - Busy Everywhere</b><br/>All possible destinations are busy. Unlike the 486 response, this response indicates the destination knows there are no alternative destinations (such as a voicemail server) able to accept the call.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '600');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '603','<b>603 - Decline</b><br/>The destination does not wish to participate in the call, or cannot do so, and additionally the destination knows there are no alternative destinations (such as a voicemail server) willing to accept the call. The response may indicate a better time to call in the Retry-After header field.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '603');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '604','<b>604 - Does Not Exist Anywhere</b><br/>The server has authoritative information that the requested user does not exist anywhere.' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '604');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '606',"<b>606 - Not Acceptable</b><br/>The user's agent was contacted successfully but some aspects of the session description such as the requested media, bandwidth, or addressing style were not acceptable." FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '606');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '608',"<b>608 - Rejected</b><br/>An intermediary machine or process rejected the call attempt. This contrasts with the 607 (Unwanted) SIP response code in which the called party rejected the call. The response may include the contact entities that blocked the call in Call-Info header containing. This provides a remediation mechanism for legal callers that find their calls blocked." FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '608');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '348',"<b>348 - MySQL query timeout</b>" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '348');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '349',"<b>349 - Vendor is blocked</b>" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '349');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '350',"<b>350 - MNP search error</b>" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '350');
UPDATE hangupcausecodes SET description = '<b>349 - Vendor is blocked</b>' WHERE code = '349';
UPDATE hangupcausecodes SET description = '<b>607 - Unwanted</b><br/>The called party did not want this call from the calling party. Future attempts from the calling party are likely to be similarly rejected.' WHERE code = '607';
UPDATE users JOIN addresses ON addresses.id = users.address_id SET users.main_email = IF(TRIM(users.main_email) = '' OR users.main_email IS NULL, addresses.email, IF(TRIM(addresses.email) = '' OR addresses.email IS NULL, users.main_email, CONCAT(users.main_email, ';', addresses.email)));
UPDATE addresses SET email = NULL;
INSERT INTO manager_rights (name, nice_name) SELECT 'USERS_Users_Kill_Calls', 'USERS > Users | Kill Calls' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'USERS_Users_Kill_Calls');
INSERT IGNORE INTO conflines (name, value) SELECT 'white_label_footer', 'M4 SBC by <a href=\"http://www.kolmisoft.com\" target=\"_blank\">Kolmisoft </a> 2006 - <span id=\"current_year\"></span><script type=\"text/javascript\"> document.getElementById(\"current_year\").innerHTML = new Date().getFullYear(); </script>' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'white_label_footer');
INSERT IGNORE INTO conflines (name, value) SELECT 'MNP_Settings_Changes_Present', '1' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines where name = 'MNP_Settings_Changes_Present');
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT 'daily_spend_warning_email', 'Daily spend warning', NOW(), 1, 'Dear <%= full_name %>,\n\nYour Daily spend limit will run out soon.', 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = 'daily_spend_warning_email');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '352',"<b>352 - User daily spend limit reached</b>" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '352');
INSERT IGNORE INTO dc_groups (id, name) SELECT 1, 'default' FROM dual WHERE NOT EXISTS (SELECT * FROM dc_groups where name = 'default');
INSERT IGNORE INTO dc_groups (id, name) SELECT 2, 'global' FROM dual WHERE NOT EXISTS (SELECT * FROM dc_groups where name = 'global');
INSERT INTO manager_rights (name, nice_name) SELECT 'BILLING_Tariffs_Tariff_Import','BILLING > Tariffs > Tariff Import' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'BILLING_Tariffs_Tariff_Import');
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT 'payment_confirmation_necessary', 'Payment confirmation necessary', NOW(), 1, 'Hello <%= full_name %>,\n\nUser <%= payments_user_full_name %> made payment of <%= payment_amount %> <%= payment_currency %>.\n\nTo approve or deny this payment, click this link: <%= payments_link %>', 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = 'payment_confirmation_necessary');
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT 'payment_rejected', 'Payment Rejected', NOW(), 1, 'Hello <%= full_name %>,\n\nYour payment of <%= payment_amount%> <%= payment_currency %> was rejected.', 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = 'payment_rejected');
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT 'payment_accepted', 'Payment Accepted', NOW(), 1, 'Hello <%= full_name %>,\n\nYour payment of <%= payment_amount%> <%= payment_currency %> was accepted.', 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = 'payment_accepted');
INSERT IGNORE INTO rate_notification_templates (name, header_rows, client_row, client_column, currency_row, currency_column, timezone_row, timezone_column, destination_group_column, destination_column, prefix_column, rate_column, effective_from_column, rate_difference_raw_column, rate_difference_percentage_column, increment_column, minimal_time_column, status_column) SELECT 'Default', 6, '2', 'C', '3', 'C', '4', 'C', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K' FROM dual WHERE NOT EXISTS (SELECT * FROM rate_notification_templates WHERE name = 'Default');
DELETE FROM manager_rights WHERE name = 'BILLING_Tariffs_Tariff_Import';
INSERT INTO manager_rights (name, nice_name) SELECT 'BILLING_Tariffs_Tariff_Import_Inbox','BILLING > Tariffs > Tariff Import Inbox' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'BILLING_Tariffs_Tariff_Import_Inbox');
INSERT INTO manager_rights (name, nice_name) SELECT 'BILLING_Tariffs_Tariff_Import_Jobs','BILLING > Tariffs > Tariff Import Jobs' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'BILLING_Tariffs_Tariff_Import_Jobs');
INSERT INTO manager_rights (name, nice_name) SELECT 'BILLING_Tariffs_Tariff_Import_Import_Rules','BILLING > Tariffs > Tariff Import Import Rules' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'BILLING_Tariffs_Tariff_Import_Import_Rules');
INSERT INTO manager_rights (name, nice_name) SELECT 'BILLING_Tariffs_Tariff_Import_Rate_Import_Rules','BILLING > Tariffs > Tariff Import Rate Import Rules' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'BILLING_Tariffs_Tariff_Import_Rate_Import_Rules');
INSERT INTO manager_rights (name, nice_name) SELECT 'BILLING_Tariffs_Tariff_Import_Templates','BILLING > Tariffs > Tariff Import Templates' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'BILLING_Tariffs_Tariff_Import_Templates');
INSERT INTO manager_rights (name, nice_name) SELECT 'BILLING_Tariffs_Tariff_Import_Link_Attachment_Rules','BILLING > Tariffs > Tariff Import Link Attachment Rules' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'BILLING_Tariffs_Tariff_Import_Link_Attachment_Rules');
UPDATE conflines SET value = 1 WHERE name = 'Allow_Dynamic_Origination_Point_Authentication_with_Registration';
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT '2FA_authentication_notification', '2FA access code', NOW(), 1, 'Dear <%= username %>,\n\nIn order to complete login process, please enter this code: <%= two_fa_code %>', 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = '2FA_authentication_notification');
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT '2FA_login_notification', 'New 2FA login from GUI', NOW(), 1, 'New login using 2FA detected.\n\nUser: <%= username %>\n\nUser page: <a href="<%= user_edit_url %>"><%= user_edit_url %></a>\n\nLogin attempt: <%= two_fa_code_attempt %>\n\nLogin status: <%= two_fa_login_status %>\n\nLogin IP: <%= two_fa_login_ip %>\n\nTime: <%= current_time %>', 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = '2FA_login_notification');
INSERT IGNORE INTO lnp_prefixes (prefix) SELECT '1' FROM dual WHERE NOT EXISTS (SELECT * FROM lnp_prefixes);
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '353',"<b>353 - LNP search error</b>" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '353');
INSERT INTO manager_rights (name, nice_name) SELECT 'USERS_Users_Deny_Balance_range_change', 'USERS > Users | Deny Balance range change' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'USERS_Users_Deny_Balance_range_change');
INSERT IGNORE INTO version (table_name, table_version) SELECT 'uacreg', "4" FROM dual WHERE NOT EXISTS (SELECT * FROM version WHERE table_name = 'uacreg');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '351',"<b>351 - MNP CIP does not match TP</b>" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '351');
INSERT IGNORE INTO conflines (name, value) SELECT 'device_auth_settings_updated', '0' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines where name = 'device_auth_settings_updated');
UPDATE devices SET auth_check_cli = 1, cli_from_from = 1 WHERE op = 1 AND (length(op_src_regexp) > 0 OR length(op_src_deny_regexp) > 0 OR length(op_source_transformation) > 0) AND (SELECT value FROM conflines WHERE name = 'device_auth_settings_updated' LIMIT 1) = 0;
UPDATE devices SET auth_check_cld = 1, cld_from_type = 2 WHERE op = 1 AND length(op_destination_transformation) > 0 AND (SELECT value FROM conflines WHERE name = 'device_auth_settings_updated' LIMIT 1) = 0;
UPDATE conflines set value = '1' WHERE name = 'device_auth_settings_updated';
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '354','354 - CLI/ANI is not in whitelist' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '354');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '355','355 - CLI/ANI is in blacklist' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '355');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '356','356 - CLD/DNIS is not accepted by regexp' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '356');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '357','357 - CLD/DNIS is not in whitelist' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '357');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '358','358 - CLD/DNIS is denied by regexp' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '358');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '359','359 - CLD/DNIS is in blacklist' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '359');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '360','360 - FROM domain is not allowed' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '360');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '361','361 - TO domain is not allowed' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '361');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '362',"362 - Terminator balance limit reached (balance min)" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '362');
INSERT IGNORE INTO conflines (name, value) SELECT 'ftp_backups_automatic_cdr_export_path', '/' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'ftp_backups_automatic_cdr_export_path');
UPDATE cdr_export_templates JOIN (SELECT x.cdr_export_templates_id_x AS cdr_export_templates_id, IF((x.user_billsec_loc > 0), IF(x.user_billsec_loc = x.originator_billsec_loc, 1, 0), 0) AS change_user_billsec FROM (SELECT id AS cdr_export_templates_id_x, FIND_IN_SET("nice_billsec", REPLACE(columns, ";", ",")) AS user_billsec_loc, FIND_IN_SET("Originator Billsec", REPLACE(nice_columns, ";", ",")) AS originator_billsec_loc FROM cdr_export_templates) AS x) AS y ON y.cdr_export_templates_id = cdr_export_templates.id SET columns = REPLACE(columns, "nice_billsec", "user_billsec") WHERE y.change_user_billsec = 1;
INSERT INTO manager_rights (name, nice_name) SELECT 'ROUTING_DIDs','ROUTING > DIDs' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'ROUTING_DIDs');
INSERT INTO manager_rights (name, nice_name) SELECT 'ACCOUNTING_Subscriptions','ACCOUNTING > Subscriptions' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'ACCOUNTING_Subscriptions');
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT 'flat_rate_user_notification_email', 'Flat-Rate Usage Notification', NOW(), 1, "Hello <%= full_name %>, this is an automatic notification email. Your Flat-Rate Service <%= flat_rate_plan_name %> reached it's limit at <%= flat_rate_plan_limit %>", 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = 'flat_rate_user_notification_email');
INSERT IGNORE INTO emails (name, subject, date_created, template, body, format, owner_id) SELECT 'subscription_insufficient_funds', 'Subscription insufficient funds', NOW(), 1, 'Dear <%= full_name %>,\n\nInsufficient funds to charge subscription', 'html', 0 FROM dual WHERE NOT EXISTS (SELECT * FROM emails WHERE name = 'subscription_insufficient_funds');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '363',"363 - DID is not active" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '363');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '364',"364 - DID is not forwarded anywhere" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '364');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '365',"365 - DID CC limit reached" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '365');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '366',"366 - DID selling rate not found" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '366');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '367',"367 - DID buying rate not found" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '367');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '368',"368 - Balance too low to make a DID call" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '368');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '369',"369 - DID authorization error" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '369');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '370',"370 - Flat-Rate authorization error" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '370');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '371',"371 - TP rate is higher than allowed in Flat-Rate" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '371');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '372',"372 - DID subscription is not active" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '372');
UPDATE directions SET name = REPLACE(LOWER(name), 'serbia and montenegro', 'Serbia') WHERE name LIKE 'Serbia and Montenegro';
UPDATE destinations SET name = REPLACE(LOWER(name), 'serbia and montenegro', 'Serbia') WHERE name LIKE 'Serbia and Montenegro';
UPDATE destinationgroups SET name = REPLACE(LOWER(name), 'serbia and montenegro', 'Serbia') WHERE name LIKE 'Serbia and Montenegro';
INSERT INTO manager_rights (name, nice_name) SELECT 'ACCOUNTING_Supplier_Invoices','ACCOUNTING > Supplier Invoices' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'ACCOUNTING_Supplier_Invoices');
INSERT INTO manager_rights (name, nice_name) SELECT 'MAINTENANCE_Disconnect_Codes','MAINTENANCE > Disconnect Codes' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'MAINTENANCE_Disconnect_Codes');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '373',"373 - DID selling rate is blocked" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '373');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '374',"374 - DID buying rate is blocked" FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '374');
INSERT INTO manager_rights (name, nice_name) SELECT 'MAINTENANCE_Managers', 'MAINTENANCE > Managers' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'MAINTENANCE_Managers');
INSERT INTO manager_rights (name, nice_name) SELECT 'ACCOUNTING_Services','ACCOUNTING > Services' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'ACCOUNTING_Services');
INSERT INTO manager_rights (name, nice_name) SELECT 'ACCOUNTING_Subscriptions_Charge_Plans','ACCOUNTING > Subscriptions > Charge Plans' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'ACCOUNTING_Subscriptions_Charge_Plans');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '375','375 - Duplicate Call' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '375');
INSERT INTO manager_rights (name, nice_name) SELECT 'SECURITY_Whitelisted_IPs', 'SECURITY > Whitelisted IPs' FROM dual WHERE NOT EXISTS (SELECT * FROM manager_rights WHERE name = 'SECURITY_Whitelisted_IPs');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '376','376 - Source number not found in TP CLI Whitelist Number Pool' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '376');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '377','377 - Source number found in TP CLI Blacklist Number Pool' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '377');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '378','378 - Destination number does not match TP CLD Whitelist Regexp' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '378');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '379','379 - Destination number not found in TP CLD Whitelist Number Pool' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '379');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '380','380 - Destination number matches TP CLD Blacklist regexp' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '380');
INSERT IGNORE INTO hangupcausecodes (code, description) SELECT '381','381 - Destination number found in TP CLD Blacklist Number Pool' FROM dual WHERE NOT EXISTS (SELECT * FROM hangupcausecodes WHERE code = '381');
INSERT IGNORE INTO conflines (name, value) SELECT 'sftp_backups_automatic_cdr_export_path', '/' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'sftp_backups_automatic_cdr_export_path');
INSERT IGNORE INTO conflines (name, value) SELECT 'sftp_port', '22' FROM dual WHERE NOT EXISTS (SELECT * FROM conflines WHERE name = 'sftp_port');
# ^^^^^^ WRITE ABOVE THIS LINE ^^^^^
# marking that DB is updated from script
INSERT INTO conflines (name, value) VALUES ('DB_Update_From_Script', 1);
