CREATE TABLE `opakovanie` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `primary_table` varchar(255) NOT NULL DEFAULT '',
  `primary_id` int(11) NOT NULL,
  `perioda_opakovania_id` int(11) NOT NULL,
  `datum_od` date NOT NULL,
  `datum_do` date DEFAULT NULL COMMENT 'táto hodnota je zadaná aj keď je zadaný počet opakovaní, pretože sa dopočíta. null môže byť ak je neurčito',
  `pocet` int(11) DEFAULT NULL,
  `interval_opakovania` int(11) DEFAULT NULL COMMENT 'počet dní',
  `mesiac` varchar(255) DEFAULT '' COMMENT '1-12',
  `tyzden` varchar(255) DEFAULT '' COMMENT '1-53',
  `den_v_mesiaci` varchar(255) DEFAULT '' COMMENT '1-31',
  `den_v_tyzdni` varchar(255) DEFAULT NULL COMMENT 'MO, TU, WE, TH, FR, SA, SU',
  `den_v_roku` varchar(255) DEFAULT NULL COMMENT '1-365',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/*2*/ ALTER TABLE `kalendar_udalost`
	DROP COLUMN `opakovanie`,
	DROP COLUMN `perioda_opakovania_id`,
	DROP COLUMN `interval_opakovania`,
	DROP COLUMN `den_v_mesiaci`,
	DROP COLUMN `pocet_opakovani`,
	DROP COLUMN `datum_opakovania_od`,
	DROP COLUMN `datum_opakovania_do`,
	DROP COLUMN `mesiac_id`;

/*1*/ DELETE FROM `form_element` WHERE  `id`=37015;
/*2*/ DELETE FROM `form_element` WHERE  `id`=37010;
/*3*/ DELETE FROM `form_element` WHERE  `id`=37011;
/*4*/ DELETE FROM `form_element` WHERE  `id`=37012;
/*5*/ DELETE FROM `form_element` WHERE  `id`=37007;
/*6*/ DELETE FROM `form_element` WHERE  `id`=37008;
/*7*/ DELETE FROM `form_element` WHERE  `id`=37009;
/*8*/ DELETE FROM `form_element` WHERE  `id`=37013;
/*9*/ DELETE FROM `form_element` WHERE  `id`=37014;
/*10*/ DELETE FROM `form_group` WHERE  `id`=37001;
/*11*/ DELETE FROM `form_group` WHERE  `id`=37002;
/*12*/ INSERT INTO `menu` (`id`, `menu_id`, `nazov`, `page`, `poradie`, `level`, `visibility_type`) VALUES (37007, 37001, 'Opakovanie udalosti', 'kalendar_udalost_opakovanie', 30, 3, 1);
/*13*/ ALTER TABLE `den`
	ADD COLUMN `day_in_week` VARCHAR(2) NULL COMMENT 'pouziva sa v opakovani' AFTER `nazov`;
/*14*/ UPDATE `den` SET `day_in_week`='MO' WHERE  `id`=1;
/*15*/ UPDATE `den` SET `day_in_week`='TU' WHERE  `id`=2;
/*16*/ UPDATE `den` SET `day_in_week`='WE' WHERE  `id`=3;
/*17*/ UPDATE `den` SET `day_in_week`='TH' WHERE  `id`=4;
/*18*/ UPDATE `den` SET `day_in_week`='FR' WHERE  `id`=5;
/*19*/ UPDATE `den` SET `day_in_week`='SA' WHERE  `id`=6;
/*20*/ UPDATE `den` SET `day_in_week`='SU' WHERE  `id`=7;

DROP TABLE kalendar_udalost_den;
