CC-5387 : Copy cc_webstream_metadata to playout_history for 2.5 upgrade

removing temp view, function.
adding showname info as well.
This commit is contained in:
Naomi 2013-10-10 10:52:18 -04:00
parent 68caf957ea
commit c6b061d46a
1 changed files with 18 additions and 10 deletions

View File

@ -6,20 +6,23 @@ SELECT file_id, starts, ends, instance_id
FROM cc_schedule FROM cc_schedule
WHERE media_item_played = true; WHERE media_item_played = true;
drop view ws_history;
create view ws_history as
select CREATE VIEW ws_history AS
SELECT
wm.start_time as starts, wm.start_time as starts,
ws.name as creator, ws.name as creator,
wm.liquidsoap_data as title, wm.liquidsoap_data as title,
sched.instance_id as instance_id sched.instance_id as instance_id,
show.name as showname
from cc_webstream_metadata as wm FROM cc_webstream_metadata AS wm
left join cc_schedule as sched LEFT JOIN cc_schedule AS sched
on sched.id = wm.instance_id ON sched.id = wm.instance_id
left join cc_webstream as ws LEFT JOIN cc_webstream AS ws
on sched.stream_id = ws.id; ON sched.stream_id = ws.id
LEFT JOIN cc_show AS show
ON sched.instance_id = show.id;
CREATE OR REPLACE FUNCTION migrateWebstreamHistory() RETURNS int4 AS $$ CREATE OR REPLACE FUNCTION migrateWebstreamHistory() RETURNS int4 AS $$
@ -40,6 +43,8 @@ BEGIN
insert into cc_playout_history_metadata (history_id, key, value) insert into cc_playout_history_metadata (history_id, key, value)
values (hisid, 'artist_name', r.creator); values (hisid, 'artist_name', r.creator);
insert into cc_playout_history_metadata (history_id, key, value)
values (hisid, 'showname', r.showname);
END LOOP; END LOOP;
return 1; return 1;
@ -47,4 +52,7 @@ END;
$$ $$
LANGUAGE plpgsql; LANGUAGE plpgsql;
SELECT migrateWebstreamHistory() as output; SELECT migrateWebstreamHistory() as output;
DROP FUNCTION migrateWebstreamHistory();
DROP VIEW ws_history;