I am creating a wordpress plugin. This plugin creates some custom tables. Using wordpress 4.1 everything was working fine. After the update to 4.2 the plugin creates only teachers and holidays tables. Here is my code:
register_activation_hook( __FILE__, 'utt_install' );
function utt_install(){
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
global $wpdb;
$periodsTable=$wpdb->prefix."utt_periods";
$subjectsTable=$wpdb->prefix."utt_subjects";
$groupsTable=$wpdb->prefix."utt_groups";
$teachersTable=$wpdb->prefix."utt_teachers";
$classroomsTable=$wpdb->prefix."utt_classrooms";
$lessonsTable=$wpdb->prefix."utt_lessons";
$holidaysTable=$wpdb->prefix."utt_holidays";
$eventsTable=$wpdb->prefix."utt_events";
$lessonsView=$wpdb->prefix."utt_lessons_view";
$sql = "CREATE TABLE IF NOT EXISTS `$periodsTable` (
`periodID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`year` YEAR NOT NULL COMMENT 'Ïο ÎÏÎ¿Ï - ÎÏÏι θα μÏοÏεί να κÏαÏηθεί και ιÏÏοÏÎ¹ÎºÏ Ïε Î²Î¬Î¸Î¿Ï ÏÏÏνοÏ
',
`semester` ENUM('Î','Χ') NOT NULL COMMENT 'ÎαÏινÏ, ΧειμεÏινÏ',
PRIMARY KEY (`periodID`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;";
dbDelta($sql);
$sql="CREATE TABLE IF NOT EXISTS `$subjectsTable` (
`subjectID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`title` VARCHAR(64) NOT NULL COMMENT 'Ïο εÏίÏημο Ïνομα ÏοÏ
μαθήμαÏοÏ',
`type` ENUM('Î','Î','ÎÎ ') NOT NULL COMMENT 'ÎεÏÏία, ÎÏγαÏÏήÏιο, ÎÏκηÏη-Î Ïάξη',
`semester` TINYINT UNSIGNED NOT NULL COMMENT 'Ïο εξάμηνο ÏÏοÏ
δÏν ÏÏο οÏοίο αÏεÏ
θÏνεÏαι Ïο μάθημα',
`is_enabled` TINYINT(1) NOT NULL DEFAULT 1 COMMENT 'εαν Ïο μάθημα είναι ενεÏÎ³Ï - η εÏαÏμογή θα ÏÏοβάλει μÏνο Ïα ενεÏγά μαθήμαÏα',
`color` VARCHAR(45) NOT NULL COMMENT 'Το ÏÏÏμα ÏοÏ
θα εμÏανίζεÏαι ÏÏο ÏÏÏγÏαμμα.',
PRIMARY KEY (`subjectID`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;";
dbDelta($sql);
$sql="CREATE TABLE IF NOT EXISTS `$groupsTable` (
`groupID` INT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Î¼Î¿Î½Î±Î´Î¹ÎºÏ Î¼ÎÏÏ ÎµÏ
ÏεÏηÏίοÏ
UQ - για ÏÏήÏη ÏÏ FKey ÏÏον Lessons',
`periodID` INT UNSIGNED NOT NULL COMMENT 'FKey αÏÏ Periods',
`subjectID` INT UNSIGNED NOT NULL COMMENT 'FKey αÏÏ Subjects',
`groupName` VARCHAR(20) NOT NULL COMMENT 'Ïο Ïνομα ÏÎ·Ï Î¿Î¼Î¬Î´Î±Ï (εÏγαÏÏηÏιακήÏ, κÏλ)',
PRIMARY KEY (`periodID`, `subjectID`, `groupName`),
INDEX `fk_Groups_Periods_idx` (`periodID` ASC),
INDEX `fk_Groups_Subject1_idx` (`subjectID` ASC),
UNIQUE INDEX `groupID_UNIQUE` (`groupID` ASC),
CONSTRAINT `fk_Groups_Periods`
FOREIGN KEY (`periodID`)
REFERENCES `$periodsTable` (`periodID`)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT `fk_Groups_Subjects`
FOREIGN KEY (`subjectID`)
REFERENCES `$subjectsTable` (`subjectID`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;";
dbDelta($sql);
$sql="CREATE TABLE IF NOT EXISTS `$teachersTable` (
`teacherID` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
`surname` VARCHAR(35) NOT NULL,
`name` VARCHAR(35) NULL,
PRIMARY KEY (`teacherID`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;";
dbDelta($sql);
$sql="CREATE TABLE IF NOT EXISTS `$classroomsTable` (
`classroomID` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(35) NOT NULL,
`type` ENUM('Î','Î') NOT NULL COMMENT 'ÎιαλÎξεÏν, ÎÏγαÏÏηÏίοÏ
',
`is_available` TINYINT(1) NOT NULL DEFAULT 1,
PRIMARY KEY (`classroomID`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;";
dbDelta($sql);
$sql="CREATE TABLE IF NOT EXISTS `$lessonsTable` (
`lessonID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`groupID` INT UNSIGNED NOT NULL COMMENT 'FKey αÏÏ Groups',
`classroomID` SMALLINT UNSIGNED NOT NULL COMMENT 'FKey αÏÏ Classrooms',
`teacherID` SMALLINT UNSIGNED NOT NULL COMMENT 'FKey αÏÏ Teachers',
`start` DATETIME NOT NULL COMMENT 'Ïο date part καθοÏίζει Ïην ημεÏομηνία και Ïο time part Ïην ÏÏα ÎναÏξηÏ',
`end` DATETIME NOT NULL,
INDEX `fk_Lesson_Classrooms1_idx` (`classroomID` ASC),
INDEX `fk_Lesson_Teachers1_idx` (`teacherID` ASC),
PRIMARY KEY (`lessonID`),
CONSTRAINT `fk_Lessons_Classrooms`
FOREIGN KEY (`classroomID`)
REFERENCES `$classroomsTable` (`classroomID`)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT `fk_Lessons_Teachers`
FOREIGN KEY (`teacherID`)
REFERENCES `$teachersTable` (`teacherID`)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT `fk_Lessons_Groups1`
FOREIGN KEY (`groupID`)
REFERENCES `$groupsTable` (`groupID`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;";
dbDelta($sql);
$sql="CREATE TABLE IF NOT EXISTS `$holidaysTable` (
`holidayDate` DATE NOT NULL,
`holidayName` VARCHAR(45) NOT NULL,
PRIMARY KEY (`holidayDate`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;";
dbDelta($sql);
$sql="CREATE TABLE IF NOT EXISTS `$eventsTable` (
`eventID` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`eventType` VARCHAR(45) NOT NULL COMMENT 'ΤÏÏÎ¿Ï ÏοÏ
ÏÏ
μβάνÏοÏ.',
`eventTitle` VARCHAR(45) NOT NULL COMMENT 'ΤίÏÎ»Î¿Ï ÏοÏ
ÏÏ
μβάνÏοÏ',
`eventDescr` VARCHAR(255) NULL COMMENT 'ΠεÏιγÏαÏή ÏοÏ
ÏÏ
μβάνÏοÏ.',
`classroomID` SMALLINT UNSIGNED NOT NULL COMMENT 'Fkey αÏÏ classrooms',
`eventStart` DATETIME NOT NULL COMMENT 'ÎμεÏομηνία - ÏÏα ÏοÏ
αÏÏίζει Ïο ÏÏ
μβάν.',
`eventEnd` DATETIME NOT NULL COMMENT 'ÎμεÏομηνία - ÏÏα ÏοÏ
ÏελειÏνει Ïο ÏÏ
μβάν.',
PRIMARY KEY (`eventID`),
INDEX `fk_wp_utt_events_wp_utt_classrooms1_idx` (`classroomID` ASC),
CONSTRAINT `fk_wp_utt_events_wp_utt_classrooms1`
FOREIGN KEY (`classroomID`)
REFERENCES `$classroomsTable` (`classroomID`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci;";
dbDelta($sql);
$wpdb->query("CREATE OR REPLACE VIEW $lessonsView AS
SELECT
periodID,
lessonID,
semester,
$lessonsTable.groupID,
$lessonsTable.classroomID,
$lessonsTable.teacherID,
start,
end,
groupName,
$subjectsTable.subjectID,
$subjectsTable.title AS subjectTitle,
$subjectsTable.type AS subjectType,
color,
$classroomsTable.name AS classroomName,
$classroomsTable.type AS classroomType,
surname as teacherSurname,
$teachersTable.name as teacherName
FROM
$lessonsTable,
$groupsTable,
$subjectsTable,
$classroomsTable,
$teachersTable
WHERE
$lessonsTable.groupID = $groupsTable.groupID
AND $groupsTable.subjectID = $subjectsTable.subjectID
AND $lessonsTable.classroomID = $classroomsTable.classroomID
AND $lessonsTable.teacherID = $teachersTable.teacherID;");
}
The problem was that after updating to wordpress 4.2, wordpress was not accepting the greek characters in commends and enum type. I had to make them english.
I answer in order to help anybody who has the same problem!