
Cargar
script-carga-bd-users.sql
script-carga-bd-event_types.sql
script-carga-bd-values.sql
script-carga-bd-venues.sql
script-carga-bd-envents_venues_aux.sql
script-carga-bd-speaker_types.sql
script-carga-bd-entidades.sql

insert into lqdvi_v2.entities_entities_types (entityid, typeid, createdAt, updatedAt)
select id, '76b17163-a167-11e9-a57c-000c295f0f58', now(), now() from `entities`

insert into lqdvi_v2.`multimedia_files` (id, name, description, type, provider, code, url, createdAt, userId, updatedAt)
SELECT a.id, a.title, a.description, 'video', a.provider, a.code, a.url, a.created, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', now()
FROM lqdvi.`video` as a;


insert into lqdvi_v2.`events` (id, name, description, init_date, init_available_date, end_available_date, gmt, assistants, confirmed, state, typeId, url_streaming, url_poll, url_registration,
userId, CreatedAt, venueId, campaign_text, UpdatedAt)
SELECT id, title, address , date, avalible, date, GMT, assistants, confirmed, status, typeId, streaming, poll, url_registration, '0939bb2a-d33d-4290-ac81-fc9faa1c015e',
 now(), '120c5a99-6e9b-4cc2-875a-af0f8db00e4b', campaign_text, now()
FROM lqdvi.conference;

update events e
set e.venueID = (select a.venueID from envents_venues_aux a where a.eventID = e.ID);


insert into lqdvi_v2.speakers
(id, name, description, slogan, twitter, facebook, youtube, linkedin, instagram, web, state, typeId, userId, createdAt, updatedAt)
SELECT id, name, description, slogan, twitter, facebook, youtube, linkedin, instagram, web, 'publish', 1, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', now(), now()
FROM lqdvi.speaker;

insert into lqdvi_v2.speakers_values (speakerid, valueId, createdAt, updatedAt)
SELECT speakerid, valueid, now(), now() FROM lqdvi.`speaker-value`;

//insertamos los videos relacionados
insert into lqdvi_v2.`multimedias` (id, entityId, entityName, multimediafileId, type, createdAt, updatedAt)
SELECT UUID() as ID, conferenceId as eventID, 'event', videoId as multimediafileid, 'relacion', now(), now() 
FROM lqdvi.`video-conference`
where videoId in (select id from lqdvi_v2.multimedia_files);

//insertamos los videos resumen de cada conferencia
insert into lqdvi_v2.`multimedias` (id, entityId, entityName, multimediafileId, type, createdAt, updatedAt)
SELECT UUID() as ID, Id as eventID, 'event', resume as multimediafileid, 'resume', now(), now() 
FROM lqdvi.`conference`
where resume in (select id from lqdvi_v2.multimedia_files);

//insertamos las imagenes de los ponentes
insert into lqdvi_v2.multimedia_files (id, name, description, type, provider, url, userId, createdAt, updatedAt)
SELECT UUID() as ID, concat(name, ' - picture'), id as speakerId, 'picture', 'cdn', picture, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', now(), now() FROM lqdvi.speaker
where picture is not null;

insert into lqdvi_v2.multimedias (id, multimediafileid, entityid, entityname, type, createdat, updatedat)
SELECT  UUID() as ID, id as multimediafileid, description as speakerid, 'speaker', 'avatar', now(), now() FROM lqdvi_v2.multimedia_files
where name like '%picture%';

insert into lqdvi_v2.multimedia_files (id, name, description, type, provider, url, userId, createdAt, updatedAt)
SELECT UUID() as ID, concat(name, ' - wallpaper'), id as speakerId, 'picture', 'cdn', wallpaper, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', now(), now() FROM lqdvi.speaker
where wallpaper is not null;

insert into lqdvi_v2.multimedias (id, multimediafileid, entityid, entityname, type, createdat, updatedat)
SELECT  UUID() as ID, id as multimediafileid, description as speakerid, 'speaker', 'wallpaper', now(), now() FROM lqdvi_v2.multimedia_files
where name like '%wallpaper%';

insert into lqdvi_v2.`multimedias` (id, entityId, entityName, multimediafileId, type, createdAt, updatedAt)
SELECT UUID() as ID, speakerID as eventID, 'speaker', videoId as multimediafileid, 'relacion-speaker', now(), now() 
FROM lqdvi.`video-speaker`
where videoId in (select id from lqdvi_v2.multimedia_files);

//Modificamos la tabla para crear otro campo autoinc que nos rellene el order
/*
insert into lqdvi_v2.events_schedules (id, eventId, speakerId, description, createdAt, updatedAt)
SELECT id, conferenceId, speakerId,  
CONCAT(DATE_FORMAT(init_hour, "%H:%i"), ' - ', COALESCE(DATE_FORMAT(end_hour, "%H:%i"),''), ' - ',  COALESCE(title,''), ' - ',COALESCE(info,'') ) as description,
now(), now() 
FROM lqdvi.event
order by conferenceId, init_hour;

update lqdvi_v2.events_schedules as a
set a.order = nuevoidorder

insert into lqdvi_v2.events_schedules (id, eventId, speakerId, order, description, createdAt, updatedAt)
select UUID() as ID, conferenceId, speakerId, 0, 'relacion conference-speaker modelo anterior', now(), now() FROM lqdvi.`conference-speaker`;
*/


//METEMOS LOS DETALLES DE LOS CONGRESOS AGENDAS DE TODOS LOS CONGRESOS
Cargar
script-carga-bd-events_details.sql


update lqdvi_v2.events_details
set type = 'speaker'
where description like'%conference-speaker%';

update lqdvi_v2.events_details
set type = 'info'
where type is null;


//RESERVAS-INVITACIONES
Crear campo entityname (varchar(255)) en tabla events_reservations

insert into lqdvi_v2.events_reservations
(id, init_available_date, end_available_date, gmt, state, 
assistants, confirmed, allow_multiple, multiple_limit, 
description, reservation_code, color,
allow_overflow, overflow_event_reservationID, marketing_list,
createdAt, updatedAt, userID, 
entityId, eventid, entityname)

SELECT b.id, init_date, end_date, gmt, status, 
assistants, confirmed, 0, 0, 
b.name as name_invitation, invitation_code, color, 
0, null, marketinglist, now(), now(), '0939bb2a-d33d-4290-ac81-fc9faa1c015e',
null, null, a.name
 
FROM lqdvi.partner a
left join lqdvi.level b on (b.partnerId = a.id);


//INSERTAMOS LAS ENTIDADES
insert into lqdvi_v2.entities
(id, name, state, createdAt, updatedAt, contact_person, contact_email )
SELECT UUID() as ID, name, 'ff', now(), now(), contact_name, contact_email 
FROM lqdvi.partner;

//ASIGNAMOS QUE SON PARTNERS
insert into lqdvi_v2.entities_entities_types
(entityid, typeid, createdAt, updatedAt)
select id, '32d6306a-aa02-11e9-a553-000c295f0f58', now(), now()
from lqdvi_v2.entities
where state = 'ff';

update lqdvi_v2.entities
set state = 'publish'
where state = 'ff';

//OJO ASIGNAMOS EVENTO SEVILLA PARA PRUEBA, ESTE DEBE SER LUEGO LA CORUÑA
update lqdvi_v2.events_reservations
set eventID = '5f772798-5616-4663-a661-b6484dd11bd7';


//ENLAZAMOS CON LAS RESERVAS


//Metemos las preguntas de los congresos
insert into lqdvi_v2.events_questions (id, eventId, speakerId, anonimous, answered, discared, answer, userId, createdAt, updatedAt)
SELECT UUID() as ID, conferenceId, speakerId, anonymous, answered, discared, content, '0939bb2a-d33d-4290-ac81-fc9faa1c015e', created, now() FROM lqdvi.question;










