ALTER TABLE category_question DROP FOREIGN KEY FK_category_question_categories_ID;
ALTER TABLE abteilung MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE activity MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE activitytype MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE answer MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE beurteilung MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
/*ALTER TABLE beurteilungart MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT; */
ALTER TABLE beurteilungsart MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE beurteilungsartGlobal MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE beurteilungsconfig MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE beurtGruppe MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE beurtGruppeLK MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE beurtGruppenDef MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
/*ALTER TABLE bewertung MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;*/
ALTER TABLE bewertungen MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE category MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE configuser MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE Cpu MODIFY COLUMN ID INT NOT NULL AUTO_INCREMENT;
ALTER TABLE datasetDefinition MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE deskriptor MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE dokumente MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE errorquestion MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE fragengruppe MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE gegenstand MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE globalconfig MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE gruppe MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE gruppeuser MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE gruppierung MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE inetlinks MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE Info MODIFY COLUMN ID INT NOT NULL AUTO_INCREMENT;
/*ALTER TABLE katalog MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;*/
ALTER TABLE katalog_fremdlehrer MODIFY COLUMN ID INT NOT NULL AUTO_INCREMENT;
ALTER TABLE klasse MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE klassenbeurteilung MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE kompetenz_beurteilung MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE kompetenz MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE kompetenz_subquestion MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE lehrerKlasse MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE lehrinhalt MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE lehrplan MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE loadedplugins MODIFY COLUMN ID INT NOT NULL AUTO_INCREMENT;
ALTER TABLE LogMsg MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE MoodleFile MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE moodleRechte MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE moodleText MODIFY COLUMN id BIGINT(20) NOT NULL AUTO_INCREMENT;
ALTER TABLE noten MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE projekte MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE questioncomment MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE question MODIFY COLUMN id BIGINT(20) NOT NULL AUTO_INCREMENT;
ALTER TABLE questiontexthistory MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE schuelergruppe MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE schuelerKlasse MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE schule MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE schuljahr MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE schultyp MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE subquestion MODIFY COLUMN id BIGINT(20) NOT NULL AUTO_INCREMENT;
ALTER TABLE subscription MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE symbolicrexexp MODIFY COLUMN ID INT NOT NULL AUTO_INCREMENT;
ALTER TABLE testAnswerSubQuestion MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE testAntwort MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE testDetails MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE testFrage MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE testGruppe MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE tests MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE testVersuch MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;
ALTER TABLE user MODIFY COLUMN id INT NOT NULL AUTO_INCREMENT;

/*ALTER TABLE questiontexthistory ADD COLUMN INFOS LONGTEXT NULL AFTER timestamp;*/
ALTER TABLE question CHANGE COLUMN `NAME` `NAME` VARCHAR(200) NULL;
ALTER TABLE question CHANGE COLUMN `NAME` `NAME` VARCHAR(200) NULL ;
ALTER TABLE activity
    CHANGE COLUMN activities_ORDER activities_ORDER INT(11) NULL DEFAULT 0 ,
    CHANGE COLUMN folder_ORDER folder_ORDER INT(11) NULL DEFAULT 0 ;
ALTER TABLE category ADD COLUMN CATEGORYLINK LONGTEXT;
ALTER TABLE tests DROP COLUMN `IDLEHRERKLASSE`;

update datasetDefinition set datasetDefinitions_ORDER=0 where datasetDefinitions_ORDER is null;
update subquestion set subQuestions_ORDER=0 where subQuestions_ORDER is null;
update moodleText set moodleTexte_ORDER=0 where moodleTexte_ORDER is null;
-- update MoodleFile set moodleFiles_ORDER=0 where moodleFiles_ORDER is null;
update MoodleFile set files_ORDER=0 where files_ORDER is null;
update answer set answers_ORDER=0 where answers_ORDER is null;

update klassenbeurteilung set klassenBeurteilungen_ORDER=0 where klassenBeurteilungen_ORDER is null;
update testFrage set testFragen_ORDER=0 where testFragen_ORDER is null;
update noten set noten_order=0 where noten_order is null;
update activity set activities_ORDER=0 where activities_ORDER is null;
update activity set folder_ORDER=0 where folder_ORDER is null;

ALTER TABLE lehrerKlasse ADD COLUMN KURSKENNUNG VARCHAR(255);
ALTER TABLE schuelerKlasse ADD COLUMN KURSKENNUNG VARCHAR(255);
ALTER TABLE beurteilungsart ADD COLUMN USEMINPROZ TINYINT(1);

ALTER TABLE category_kompetenz DROP FOREIGN KEY FK_category_kompetenz_kompetenzen_ID;
ALTER TABLE category DROP FOREIGN KEY FK_category_KOMP_ID;

ALTER TABLE kompetenz_subquestion DROP FOREIGN KEY FK_kompetenz_subquestion_kompetenzID;
ALTER TABLE kompetenz_subquestion DROP FOREIGN KEY FK_kompetenz_subquestion_subQuestionsID;

ALTER TABLE lehrplan DROP FOREIGN KEY FK_lehrplan_idAbteilung;
ALTER TABLE lehrplan DROP FOREIGN KEY FK_lehrplan_idSchultyp;
ALTER TABLE kompetenz DROP FOREIGN KEY FK_kompetenz_idAbteilung;
ALTER TABLE kompetenz DROP FOREIGN KEY FK_kompetenz_idSchultyp;


