 $$ 
 LANGUAGE plpgsql;
 
-SELECT migrateWebstreamHistory() as output;+SELECT migrateWebstreamHistory() as output;
+
+DROP FUNCTION migrateWebstreamHistory();
+DROP VIEW ws_history;
            insert into cc_playout_history_metadata (history_id, key, value)
            values (hisid, 'artist_name', r.creator);

            
    END LOOP;
return 1;

FROM cc_schedule
WHERE media_item_played = true;


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,
show.name as showname

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
LEFT JOIN cc_show AS show
ON sched.instance_id = show.id;


CREATE OR REPLACE FUNCTION migrateWebstreamHistory() RETURNS int4 AS $$
