-- ### ab_bodies ###
INSERT INTO `ab_bodies`
SELECT * FROM `photo`.`ab_bodies`;

UPDATE `ab_bodies` SET `email` = NULL WHERE `email` = '';
UPDATE `ab_bodies` SET `netcomcode` = NULL WHERE `netcomcode` = '';
UPDATE `ab_bodies` SET `countrycode` = NULL WHERE `countrycode` = '';

-- ### user ###
INSERT INTO `user`
SELECT `uid`, `bodycode`, `name`, `email`, `access` FROM `photo`.`user`;

-- ### event ###
INSERT INTO `ab_bodies` (`BodyCode`, `BodyName`, `Email`, `BodyStatus`, `BodyCategory`, `BodyCategoryOrder`, `BodyNameAscii`, `NetcomCode`, `CountryCode`) VALUES
('EEC', 'EURECA - European Education Campaign', 'eureca@aegee.uni-karlsruhe.de', '-', 'Projects', 6, 'EURECA - European Education Campaign', 'z', 'B');
UPDATE `photo`.`event` SET `bodycode2` = 'XIE' WHERE `bodycode2` = 'ACA';

INSERT INTO `event`
SELECT `eventcode`, `bodycode`, `bodycode2`, `title`, `topic`, `projectname`, `location`, `datestart`, `dateend`,
	`eventtype`, `calofficial`, `certainty`, `area`, `eventrating`, `url`
FROM `photo`.`event`;

UPDATE `event` SET `bodycode2` = NULL WHERE `bodycode2` = '';
UPDATE `event` SET `topic` = NULL WHERE `topic` = '';
UPDATE `event` SET `projectname` = NULL WHERE `projectname` = '';
UPDATE `event` SET `location` = NULL WHERE `location` = '';
UPDATE `event` SET `eventtype` = NULL WHERE `eventtype` = '';
UPDATE `event` SET `url` = NULL WHERE `url` = '';

INSERT INTO `event` (`eventcode`, `bodycode`, `bodycode2`, `title`, `topic`, `projectname`, `location`, `datestart`, `dateend`,
	`eventtype`, `calofficial`, `certainty`, `area`, `eventrating`, `url`)
VALUES ('EV05KBH6', 'KBH', NULL, 'Summer University K&oslash;benhavn', NULL, NULL, 'K&oslash;benhavn', '2005-07-01', '2005-07-14',
	'SC', 'no', '', '', 'summer university', NULL)
;

-- ### book ###
INSERT INTO `book`
SELECT * FROM `photo`.`book` WHERE `uid` != 0 AND `id` NOT IN (1703, 1761, 1762, 1916, 2238, 2323, 2561);


-- ### photo ###
INSERT INTO `photo`
SELECT * FROM `photo`.`photo`;

UPDATE `photo` SET `photo_big` = `photo_normal`, `height_big` = `height_normal`, `width_big` = `width_normal` WHERE `photo_big` IS NULL;


-- ### Checks ###
SELECT *
FROM `photo`.`event` `e`
LEFT JOIN `photo`.`ab_bodies` `b` ON `b`.`bodycode` = `e`.`bodycode`
WHERE `b`.`bodycode` IS NULL
;

SELECT *
FROM `photo`.`book` `b`
LEFT JOIN `photo`.`user` `u` ON `u`.`uid` = `b`.`uid`
WHERE `u`.`uid` IS NULL
;
SELECT *
FROM `photo`.`book` `b`
LEFT JOIN `photo`.`event` `e` ON `e`.`eventcode` = `b`.`eventcode`
WHERE `e`.`eventcode` IS NULL AND `b`.`uid` != 0
;


