--
-- script de migration du posh 2.2 vers 2.3 MAJ 01/02/2013
--

-- --------------------------------------------------------

USE `posh`;

-- Modification de la structure de la table `adm_config`
ALTER TABLE `adm_config` CHANGE `parameter` `parameter` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;

-- Modification de la structure de la table `adm_log`
ALTER TABLE `adm_log` ADD `admin_id` INT( 10 ) NOT NULL AFTER `id` ;

-- Modification de la structure de la table `adm_plugins`
ALTER TABLE `adm_plugins` CHANGE `forced` `forced` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0';

-- Modification de la structure de la table `adm_tabs_map`
ALTER TABLE `adm_tabs_map` CHANGE `user_id` `user_id` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0';

-- Modification de la structure de la table `applications`
ALTER TABLE `applications` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

-- Modification de la structure de la table `applications_groups_map`
ALTER TABLE `applications_groups_map` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

-- Modification de la structure de la table `captcha_codes`
ALTER TABLE `captcha_codes` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

-- Modification de la structure de la table `dir_item`
ALTER TABLE `dir_item`  ADD `average_rating` FLOAT NOT NULL,  ADD `total_rating` INT(10) NOT NULL,  ADD `sum_rating` INT(10) NOT NULL;

-- Modification de la structure de la table `dir_item_external`
ALTER TABLE `dir_item_external` CHANGE `source` `source` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
ALTER TABLE `dir_item_external` CHANGE `xmlmodule` `xmlmodule` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;

-- Modification de la structure de la table `documents`
ALTER TABLE `documents` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

-- Modification de la structure de la table `log`
ALTER TABLE `log` CHANGE `pubdate` `pubdate` DATETIME NOT NULL DEFAULT '0000-00-00';


-- Modification de la structure de la table `network`
ALTER TABLE `network` ADD `status` CHAR( 1 ) NOT NULL DEFAULT '0' AFTER `description` ;

-- Modification de la structure de la table `network_alerts`
ALTER TABLE `network_alerts` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

-- Modification de la structure de la table `notebook_article_document_map`
ALTER TABLE `notebook_article_document_map` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

-- Modification de la structure de la table `notebook_article_keywords`
ALTER TABLE `notebook_article_keywords` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

-- Modification de la structure de la table `notebook_groups`
ALTER TABLE `notebook_groups` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

-- Modification de la structure de la table `notebook_groups_articles_map`
ALTER TABLE `notebook_groups_articles_map` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

-- Modification de la structure de la table `notebook_groups_users_map`
ALTER TABLE `notebook_groups_users_map` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE `notebook_groups_users_map` ADD `invitator_id` INT( 10 ) UNSIGNED NOT NULL AFTER `status` ;

-- Modification de la structure de la table `notebook_groups_widgets`
ALTER TABLE `notebook_groups_widgets` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

-- Modification de la structure de la table `pages`
ALTER TABLE `pages`  ADD `directories` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL,  ADD `template` SMALLINT UNSIGNED NOT NULL DEFAULT '0';

-- Modification de la structure de la table `profile`
ALTER TABLE `profile` CHANGE `param` `param` VARCHAR( 150 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL ;
ALTER TABLE `profile` ADD `template` SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT '0';

-- Modification de la structure de la table `temp_dir_item_external`
ALTER TABLE `temp_dir_item_external` CHANGE `source` `source` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;
ALTER TABLE `temp_dir_item_external` CHANGE `xmlmodule` `xmlmodule` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;

-- Modification de la structure de la table `users`
ALTER TABLE `users` ADD `email` VARCHAR( 150 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL AFTER `md5user`;
ALTER TABLE `users` CHANGE `statdate` `statdate` DATETIME NULL DEFAULT NULL ;
ALTER TABLE `users`  ADD `password_change_date` DATE NOT NULL,  ADD `force_user_change_password` TINYINT(4) NOT NULL DEFAULT '0';

-- Modification de la structure de la table `users_control`
ALTER TABLE `users_control` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

-- Modification de la structure de la table `users_group_category_map`
ALTER TABLE `users_group_category_map` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

-- Modification de la structure de la table `users_group_map`
ALTER TABLE users_group_map ADD PRIMARY KEY (user_id,group_id);

-- Réinitialisation des plugins
TRUNCATE TABLE `adm_plugins`;
INSERT INTO `adm_plugins` (`name`, `link`, `dependency`, `status`, `forced`) VALUES
('Enterprise main tools', 'enterprise_edition/enterprise_edition.php', 'no', 'O', 1),
('Plugin CAS', 'plugin_eolecas/plugin_eolecas.php', 'no', 'O', 1),
('Plugin Auto Create', 'plugin_eoleac/plugin_eoleac.php', 'no', 'O', 1),
('Plugin Desktop', 'plugin_desktop/plugin_desktop.php', 'no', 'O', 1),
('Plugin Thumbs', 'plugin_thumbs/plugin_thumbs.php', 'no', 'O', 1),
('Plugin Password', 'plugin_password/plugin_password.php', 'no', 'O', 0),
('Plugin Xdesktop', 'plugin_xdesktop/plugin_xdesktop.php', 'no', 'O', 0),
('Plugin Charte', 'plugin_charte/plugin_charte.php', 'no', 'O', 0),
('Plugin Widget Ressource', 'plugin_widget_ressource/plugin.php', 'no', 'O', 0);
