Created
June 30, 2016 20:06
-
-
Save gvagenas/3aac061eba86081f4f5e05cc90a9b0d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE ${RESTCOMM_DBNAME}; | |
DELIMITER // | |
CREATE PROCEDURE updateProcedure() | |
BEGIN | |
SELECT DISTINCTROW IFNULL(column_name, '') INTO @colName | |
FROM information_schema.columns | |
WHERE table_name = 'restcomm_call_detail_records' | |
AND column_name = 'instanceid'; | |
IF @colName IS NULL THEN | |
CREATE TABLE temp_table LIKE restcomm_call_detail_records; | |
ALTER TABLE temp_table ADD instanceid VARCHAR(255); | |
INSERT INTO temp_table | |
( | |
sid, | |
parent_call_sid, | |
date_created, | |
date_updated, | |
account_sid, | |
sender, | |
recipient, | |
phone_number_sid, | |
status, | |
start_time, | |
end_time, | |
duration, | |
price, | |
direction, | |
answered_by, | |
api_version, | |
forwarded_from, | |
caller_name, | |
uri, | |
call_path, | |
ring_duration | |
) SELECT | |
sid as sid, | |
parent_call_sid as parent_call_sid, | |
date_created as date_created, | |
date_updated as date_updated, | |
account_sid as account_sid, | |
sender as sender, | |
recipient as recipient, | |
phone_number_sid as phone_number_sid, | |
status as status, | |
start_time as start_time, | |
end_time as end_time, | |
duration as duration, | |
price as price, | |
direction as direction, | |
answered_by as answered_by, | |
api_version as api_version, | |
forwarded_from as forwarded_from, | |
caller_name as caller_name, | |
uri as uri, | |
call_path as call_path, | |
ring_duration as ring_duration | |
FROM restcomm_call_detail_records; | |
DROP TABLE restcomm_call_detail_records; | |
ALTER TABLE temp_table RENAME restcomm_call_detail_records; | |
END IF; | |
END // | |
DELIMITER; | |
CALL updateProcedure(); | |
drop procedure updateProcedure; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment