INSERT INTO SITE (`OJB_CONCRETE_CLASS`, `KEY_ROOT_DOMAIN_OBJECT`, `SITE_TYPE`)
	VALUES ('net.sourceforge.fenixedu.domain.SiteTemplate', 1, 'net.sourceforge.fenixedu.domain.DegreeSite');

INSERT INTO `ACCESSIBLE_ITEM` (`OJB_CONCRETE_CLASS`, `KEY_ROOT_DOMAIN_OBJECT`, `VISIBLE`, `KEY_SITE`, `SECTION_ORDER`, `KEY_FUNCTIONALITY`) 
	SELECT 'net.sourceforge.fenixedu.domain.FunctionalitySection', 1, 1, -1, 0, AI.`ID_INTERNAL`
	FROM `ACCESSIBLE_ITEM` AS AI WHERE AI.UUID = 'd30145de-ed6b-4abb-a760-50753d4de23b';

INSERT INTO `ACCESSIBLE_ITEM` (`OJB_CONCRETE_CLASS`, `KEY_ROOT_DOMAIN_OBJECT`, `VISIBLE`, `KEY_SITE`, `SECTION_ORDER`, `KEY_FUNCTIONALITY`) 
	SELECT 'net.sourceforge.fenixedu.domain.FunctionalitySection', 1, 1, -1, 1, AI.`ID_INTERNAL`
	FROM `ACCESSIBLE_ITEM` AS AI WHERE AI.UUID = 'b36012ae-41f4-401d-9297-2f5d2e55c5da';

INSERT INTO `ACCESSIBLE_ITEM` (`OJB_CONCRETE_CLASS`, `KEY_ROOT_DOMAIN_OBJECT`, `VISIBLE`, `KEY_SITE`, `SECTION_ORDER`, `KEY_FUNCTIONALITY`) 
	SELECT 'net.sourceforge.fenixedu.domain.FunctionalitySection', 1, 1, -1, 2, AI.`ID_INTERNAL`
	FROM `ACCESSIBLE_ITEM` AS AI WHERE AI.UUID = '5204408e-7703-413d-adec-bc50eeebc1f3';

INSERT INTO `ACCESSIBLE_ITEM` (`OJB_CONCRETE_CLASS`, `KEY_ROOT_DOMAIN_OBJECT`, `VISIBLE`, `KEY_SITE`, `SECTION_ORDER`, `KEY_FUNCTIONALITY`) 
	SELECT 'net.sourceforge.fenixedu.domain.FunctionalitySection', 1, 1, -1, 3, AI.`ID_INTERNAL`
	FROM `ACCESSIBLE_ITEM` AS AI WHERE AI.UUID = 'febb72c5-4263-43f4-bcc5-5df5eac6e148';

INSERT INTO `ACCESSIBLE_ITEM` (`OJB_CONCRETE_CLASS`, `KEY_ROOT_DOMAIN_OBJECT`, `VISIBLE`, `KEY_SITE`, `SECTION_ORDER`, `KEY_FUNCTIONALITY`) 
	SELECT 'net.sourceforge.fenixedu.domain.FunctionalitySection', 1, 1, -1, 4, AI.`ID_INTERNAL`
	FROM `ACCESSIBLE_ITEM` AS AI WHERE AI.UUID = 'd1f52ea5-1280-4ae0-ac2e-e43ca44dad34';

INSERT INTO `ACCESSIBLE_ITEM` (`OJB_CONCRETE_CLASS`, `KEY_ROOT_DOMAIN_OBJECT`, `VISIBLE`, `KEY_SITE`, `SECTION_ORDER`, `KEY_FUNCTIONALITY`) 
	SELECT 'net.sourceforge.fenixedu.domain.FunctionalitySection', 1, 1, -1, 5, AI.`ID_INTERNAL`
	FROM `ACCESSIBLE_ITEM` AS AI WHERE AI.UUID = 'e570d796-43e6-4499-87bb-99a59bd3b608';

INSERT INTO `ACCESSIBLE_ITEM` (`OJB_CONCRETE_CLASS`, `KEY_ROOT_DOMAIN_OBJECT`, `VISIBLE`, `KEY_SITE`, `SECTION_ORDER`, `KEY_FUNCTIONALITY`) 
	SELECT 'net.sourceforge.fenixedu.domain.FunctionalitySection', 1, 1, -1, 6, AI.`ID_INTERNAL`
	FROM `ACCESSIBLE_ITEM` AS AI WHERE AI.UUID = '10085a1d-de69-4803-af0f-c084a80f37fe';

INSERT INTO `ACCESSIBLE_ITEM` (`OJB_CONCRETE_CLASS`, `KEY_ROOT_DOMAIN_OBJECT`, `VISIBLE`, `KEY_SITE`, `SECTION_ORDER`, `KEY_FUNCTIONALITY`) 
	SELECT 'net.sourceforge.fenixedu.domain.FunctionalitySection', 1, 1, -1, 7, AI.`ID_INTERNAL`
	FROM `ACCESSIBLE_ITEM` AS AI WHERE AI.UUID = '7e7160fe-0f68-4886-9599-8dc92ba4eb12';

UPDATE `ACCESSIBLE_ITEM` AS AI, `SITE` AS S
	SET AI.`KEY_SITE` = S.`ID_INTERNAL`
	WHERE AI.`OJB_CONCRETE_CLASS` LIKE 'net.sourceforge.fenixedu.domain.FunctionalitySection'
		AND AI.`KEY_SITE` = -1
		AND S.`OJB_CONCRETE_CLASS` LIKE 'net.sourceforge.fenixedu.domain.SiteTemplate'
		AND S.`SITE_TYPE` LIKE 'net.sourceforge.fenixedu.domain.DegreeSite';
