CC-5387 : Copy cc_webstream_metadata to playout_history for 2.5 upgrade
This commit is contained in:
parent
b923a45ac6
commit
68caf957ea
1 changed files with 44 additions and 1 deletions
|
@ -5,3 +5,46 @@ INSERT INTO cc_playout_history (file_id, starts, ends, instance_id)
|
||||||
SELECT file_id, starts, ends, instance_id
|
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
|
||||||
|
wm.start_time as starts,
|
||||||
|
ws.name as creator,
|
||||||
|
wm.liquidsoap_data as title,
|
||||||
|
sched.instance_id as instance_id
|
||||||
|
|
||||||
|
from cc_webstream_metadata as wm
|
||||||
|
left join cc_schedule as sched
|
||||||
|
on sched.id = wm.instance_id
|
||||||
|
left join cc_webstream as ws
|
||||||
|
on sched.stream_id = ws.id;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION migrateWebstreamHistory() RETURNS int4 AS $$
|
||||||
|
|
||||||
|
DECLARE r RECORD;
|
||||||
|
DECLARE hisid integer;
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
FOR r IN SELECT * from ws_history LOOP
|
||||||
|
|
||||||
|
insert into cc_playout_history (starts, instance_id)
|
||||||
|
values (r.starts, r.instance_id)
|
||||||
|
returning id into hisid;
|
||||||
|
|
||||||
|
insert into cc_playout_history_metadata (history_id, key, value)
|
||||||
|
values (hisid, 'track_title', r.title);
|
||||||
|
|
||||||
|
insert into cc_playout_history_metadata (history_id, key, value)
|
||||||
|
values (hisid, 'artist_name', r.creator);
|
||||||
|
|
||||||
|
|
||||||
|
END LOOP;
|
||||||
|
return 1;
|
||||||
|
END;
|
||||||
|
$$
|
||||||
|
LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
SELECT migrateWebstreamHistory() as output;
|
Loading…
Add table
Add a link
Reference in a new issue