<?php
// création de la colonne code dans _eleves et dans _elevesmaj
mysqli_query($bdd,"ALTER TABLE ".$prefix."_eleves ADD code VARCHAR ( 50 ) DEFAULT NULL");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_elevesmaj ADD code VARCHAR ( 50 ) DEFAULT NULL");

// création de la colonne docname dans _seqdocs
mysqli_query($bdd,"ALTER TABLE ".$prefix."_seqdocs ADD docname TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");

// augmentation du varchar mdp des users
mysqli_query($bdd,"ALTER TABLE ".$prefix."_user MODIFY mdp VARCHAR( 200 )");

// création des paramètres pour barcodes
$verif_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'barcodes_txt'"));
if($verif_nb==0) {
	mysqli_query($bdd,"INSERT INTO ".$prefix."_parametres (param_nom, valeur, comments) VALUES ('barcodes_txt', 'IDLOG', 'Texte choisi pour le début du code élève.')");
}
$verif_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'barcodes_int'"));
if($verif_nb==0) {
	mysqli_query($bdd,"INSERT INTO ".$prefix."_parametres (param_nom, valeur, comments) VALUES ('barcodes_int', '9', 'Nombre de chiffres pour le code élève.')");
}

// augmentation du varchar valeur des parametres
mysqli_query($bdd,"ALTER TABLE ".$prefix."_parametres MODIFY valeur VARCHAR( 300 )");
// création de l'option de réservation par chaque élève avec son code
$verif_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_reseleve'"));
if($verif_nb==0) {
	mysqli_query($bdd,"INSERT INTO ".$prefix."_parametres (param_nom, valeur, comments) VALUES ('freq_reseleve', '0', 'Option de réservation par chaque élève avec son code.')");
}
$verif_nb = mysqli_num_rows(mysqli_query($bdd,"SELECT * FROM ".$prefix."_parametres WHERE param_nom = 'freq_reseleve_mdp'"));
if($verif_nb==0) {
	mysqli_query($bdd,"INSERT INTO ".$prefix."_parametres (param_nom, valeur, comments) VALUES ('freq_reseleve_mdp', '', 'Option de réservation par chaque élève avec son code.')");
}

// ///////////////

// uniformisation des encodage utf8_unicode_ci

mysqli_query($bdd,"ALTER TABLE ".$prefix."_calendrier DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtbrik DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtbrik MODIFY code VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtbrik MODIFY summary VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtbrik MODIFY division TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtbrik MODIFY textelibre VARCHAR( 30 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");

mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtcode DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtcode MODIFY code VARCHAR( 10 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtcode MODIFY code VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtcode MODIFY bgcolor_code VARCHAR( 7 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");

mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtevent DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtevent MODIFY dtstart VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtevent MODIFY dtend VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");

mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtnivcolor DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtnivcolor MODIFY niveau VARCHAR( 1 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_edtnivcolor MODIFY bgcolor VARCHAR( 7 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");

mysqli_query($bdd,"ALTER TABLE ".$prefix."_freq DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_freq MODIFY division TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_freq MODIFY sexe CHAR( 1 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL");

mysqli_query($bdd,"ALTER TABLE ".$prefix."_freqres DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_freqres MODIFY code_freqres VARCHAR( 25 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");

mysqli_query($bdd,"ALTER TABLE ".$prefix."_freqresref DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");

mysqli_query($bdd,"ALTER TABLE ".$prefix."_groupele DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");

mysqli_query($bdd,"ALTER TABLE ".$prefix."_groupes DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_groupes MODIFY groupe_nom VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_groupes MODIFY groupe_desc TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL");

mysqli_query($bdd,"ALTER TABLE ".$prefix."_hordemis DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_hordemis MODIFY demijour VARCHAR( 5 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");

mysqli_query($bdd,"ALTER TABLE ".$prefix."_retards DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_retards MODIFY titre VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");

mysqli_query($bdd,"ALTER TABLE ".$prefix."_seqdocs DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
mysqli_query($bdd,"ALTER TABLE ".$prefix."_seqdocs MODIFY docurl TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL");

mysqli_query($bdd,"ALTER TABLE ".$prefix."_seqeleves DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");

mysqli_query($bdd,"ALTER TABLE ".$prefix."_userevent DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");

// //////////////////////

// version bdd :
mysqli_query($bdd,"UPDATE ".$prefix."_parametres SET valeur = '0.22' WHERE param_nom = 'version_bdd'");

?>