--
-- Updated on v2.5
--

-- CHANGE CERTIFICATES TABLE COLUMNS;
ALTER TABLE `#__splms_certificates` CHANGE COLUMN `splms_certificate_id` `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `#__splms_certificates` CHANGE COLUMN `splms_coursescategory_id` `coursescategory_id` int(11) DEFAULT NULL;
ALTER TABLE `#__splms_certificates` CHANGE COLUMN `splms_course_id` `course_id` int(11) DEFAULT NULL;

ALTER TABLE `#__splms_certificates` CHANGE COLUMN `enabled` `published` tinyint(1) NOT NULL DEFAULT '1';
ALTER TABLE `#__splms_certificates` CHANGE COLUMN `created_on` `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_certificates` CHANGE COLUMN `modified_on` `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_certificates` CHANGE COLUMN `locked_by` `checked_out` bigint(20) NOT NULL DEFAULT '0';
ALTER TABLE `#__splms_certificates` CHANGE COLUMN `locked_on` `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';

-- CHANGE COURSES TABLE COLUMNS;
ALTER TABLE `#__splms_courses` CHANGE COLUMN `splms_course_id` `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `#__splms_courses` CHANGE COLUMN `slug` `alias` varchar(255) NOT NULL DEFAULT '';
ALTER TABLE `#__splms_courses` CHANGE COLUMN `splms_coursescategory_id` `coursecategory_id` int(11) DEFAULT NULL;
ALTER TABLE `#__splms_courses` CHANGE COLUMN `short_description` `short_description` varchar(255);
ALTER TABLE `#__splms_courses` CHANGE COLUMN `course_time` `course_time` varchar(255) NOT NULL DEFAULT '';

ALTER TABLE `#__splms_courses` CHANGE COLUMN `enabled` `published` tinyint(1) NOT NULL DEFAULT '1';
ALTER TABLE `#__splms_courses` CHANGE COLUMN `created_on` `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_courses` CHANGE COLUMN `modified_on` `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_courses` CHANGE COLUMN `locked_by` `checked_out` bigint(20) NOT NULL DEFAULT '0';
ALTER TABLE `#__splms_courses` CHANGE COLUMN `locked_on` `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';

-- CHANGE COURSE CATEGORIES TABLE COLUMNS;
ALTER TABLE `#__splms_coursescategories` CHANGE COLUMN `splms_coursescategory_id` `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `#__splms_coursescategories` CHANGE COLUMN `slug` `alias` varchar(255) NOT NULL DEFAULT '';

ALTER TABLE `#__splms_coursescategories` CHANGE COLUMN `enabled` `published` tinyint(1) NOT NULL DEFAULT '1';
ALTER TABLE `#__splms_coursescategories` CHANGE COLUMN `created_on` `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_coursescategories` CHANGE COLUMN `modified_on` `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_coursescategories` CHANGE COLUMN `locked_by` `checked_out` bigint(20) NOT NULL DEFAULT '0';
ALTER TABLE `#__splms_coursescategories` CHANGE COLUMN `locked_on` `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';

-- CHANGE EVENT CATEGORIES TABLE COLUMNS;
ALTER TABLE `#__splms_eventcategories` CHANGE COLUMN `splms_eventcategory_id` `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `#__splms_eventcategories` CHANGE COLUMN `slug` `alias` varchar(255) NOT NULL DEFAULT '';

ALTER TABLE `#__splms_eventcategories` CHANGE COLUMN `enabled` `published` tinyint(1) NOT NULL DEFAULT '1';
ALTER TABLE `#__splms_eventcategories` CHANGE COLUMN `created_on` `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_eventcategories` CHANGE COLUMN `modified_on` `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_eventcategories` CHANGE COLUMN `locked_by` `checked_out` bigint(20) NOT NULL DEFAULT '0';
ALTER TABLE `#__splms_eventcategories` CHANGE COLUMN `locked_on` `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';

-- CHANGE EVENTS TABLE COLUMNS;
ALTER TABLE `#__splms_events` CHANGE COLUMN `splms_event_id` `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `#__splms_events` CHANGE COLUMN `slug` `alias` varchar(255) NOT NULL DEFAULT '';
ALTER TABLE `#__splms_events` CHANGE COLUMN `splms_speaker_id` `speaker_id` varchar(50) DEFAULT '';
ALTER TABLE `#__splms_events` CHANGE COLUMN `splms_eventcategory_id` `eventcategory_id` bigint(20) NOT NULL;

ALTER TABLE `#__splms_events` CHANGE COLUMN `enabled` `published` tinyint(1) NOT NULL DEFAULT '1';
ALTER TABLE `#__splms_events` CHANGE COLUMN `created_on` `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_events` CHANGE COLUMN `modified_on` `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_events` CHANGE COLUMN `locked_by` `checked_out` bigint(20) NOT NULL DEFAULT '0';
ALTER TABLE `#__splms_events` CHANGE COLUMN `locked_on` `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';

-- CHANGE LESSONS TABLE COLUMNS;
ALTER TABLE `#__splms_lessons` CHANGE COLUMN `splms_lesson_id` `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `#__splms_lessons` CHANGE COLUMN `slug` `alias` varchar(255) NOT NULL DEFAULT '';
ALTER TABLE `#__splms_lessons` CHANGE COLUMN `splms_teacher_id` `teacher_id` int(11) NOT NULL;
ALTER TABLE `#__splms_lessons` CHANGE COLUMN `splms_course_id` `course_id` bigint(20) NOT NULL;

ALTER TABLE `#__splms_lessons` CHANGE COLUMN `enabled` `published` tinyint(1) NOT NULL DEFAULT '1';
ALTER TABLE `#__splms_lessons` CHANGE COLUMN `created_on` `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_lessons` CHANGE COLUMN `modified_on` `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_lessons` CHANGE COLUMN `locked_by` `checked_out` bigint(20) NOT NULL DEFAULT '0';
ALTER TABLE `#__splms_lessons` CHANGE COLUMN `locked_on` `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';

-- CHANGE ORDERS TABLE COLUMNS;
ALTER TABLE `#__splms_orders` CHANGE COLUMN `splms_order_id` `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `#__splms_orders` CHANGE COLUMN `splms_course_id` `course_id` bigint(20) NOT NULL;

ALTER TABLE `#__splms_orders` CHANGE COLUMN `enabled` `published` tinyint(1) NOT NULL DEFAULT '1';
ALTER TABLE `#__splms_orders` CHANGE COLUMN `created_on` `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_orders` CHANGE COLUMN `modified_on` `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_orders` CHANGE COLUMN `locked_by` `checked_out` bigint(20) NOT NULL DEFAULT '0';
ALTER TABLE `#__splms_orders` CHANGE COLUMN `locked_on` `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';

-- CHANGE QUIZ QUESTIONS TABLE COLUMNS;
ALTER TABLE `#__splms_quizquestions` CHANGE COLUMN `splms_quizquestion_id` `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `#__splms_quizquestions` CHANGE COLUMN `slug` `alias` varchar(255) NOT NULL DEFAULT '';
ALTER TABLE `#__splms_quizquestions` CHANGE COLUMN `splms_course_id` `course_id` bigint(20) NOT NULL;

ALTER TABLE `#__splms_quizquestions` CHANGE COLUMN `enabled` `published` tinyint(1) NOT NULL DEFAULT '1';
ALTER TABLE `#__splms_quizquestions` CHANGE COLUMN `created_on` `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_quizquestions` CHANGE COLUMN `modified_on` `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_quizquestions` CHANGE COLUMN `locked_by` `checked_out` bigint(20) NOT NULL DEFAULT '0';
ALTER TABLE `#__splms_quizquestions` CHANGE COLUMN `locked_on` `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';

-- CHANGE QUIZ QUIZ RESULTS COLUMNS;
ALTER TABLE `#__splms_quizresults` CHANGE COLUMN `splms_quizresult_id` `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `#__splms_quizresults` CHANGE COLUMN `splms_quizquestion_id` `quizquestion_id` bigint(20) NOT NULL;
ALTER TABLE `#__splms_quizresults` CHANGE COLUMN `splms_course_id` `course_id` bigint(20) NOT NULL;

ALTER TABLE `#__splms_quizresults` CHANGE COLUMN `enabled` `published` tinyint(1) NOT NULL DEFAULT '1';

-- CHANGE SPEAKERS TABLE COLUMNS;
ALTER TABLE `#__splms_speakers` CHANGE COLUMN `splms_speaker_id` `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `#__splms_speakers` CHANGE COLUMN `slug` `alias` varchar(255) NOT NULL DEFAULT '';

ALTER TABLE `#__splms_speakers` CHANGE COLUMN `enabled` `published` tinyint(1) NOT NULL DEFAULT '1';
ALTER TABLE `#__splms_speakers` CHANGE COLUMN `created_on` `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_speakers` CHANGE COLUMN `modified_on` `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_speakers` CHANGE COLUMN `locked_by` `checked_out` bigint(20) NOT NULL DEFAULT '0';
ALTER TABLE `#__splms_speakers` CHANGE COLUMN `locked_on` `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';

-- CHANGE TEACHERS TABLE COLUMNS;
ALTER TABLE `#__splms_teachers` CHANGE COLUMN `splms_teacher_id` `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT;
ALTER TABLE `#__splms_teachers` CHANGE COLUMN `slug` `alias` varchar(255) NOT NULL DEFAULT '';

ALTER TABLE `#__splms_teachers` CHANGE COLUMN `enabled` `published` tinyint(1) NOT NULL DEFAULT '1';
ALTER TABLE `#__splms_teachers` CHANGE COLUMN `created_on` `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_teachers` CHANGE COLUMN `modified_on` `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE `#__splms_teachers` CHANGE COLUMN `locked_by` `checked_out` bigint(20) NOT NULL DEFAULT '0';
ALTER TABLE `#__splms_teachers` CHANGE COLUMN `locked_on` `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00';

-- ADD QUIZRESULT TABLE COLUMNS;
ALTER TABLE `#__splms_quizresults` ADD `created_by` bigint(20) NOT NULL DEFAULT '0' AFTER `ordering`;
ALTER TABLE `#__splms_quizresults` ADD `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `created_by`;
ALTER TABLE `#__splms_quizresults` ADD `modified_by` bigint(20) NOT NULL DEFAULT '0' AFTER `created`;
ALTER TABLE `#__splms_quizresults` ADD `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `modified_by`;
ALTER TABLE `#__splms_quizresults` ADD `checked_out` bigint(20) NOT NULL DEFAULT '0' AFTER `modified`;
ALTER TABLE `#__splms_quizresults` ADD `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `checked_out`;

-- ADD COURSES TABLE COLUMNS;
ALTER TABLE `#__splms_courses` ADD `level` varchar(55) NOT NULL DEFAULT '' AFTER `short_description`;
ALTER TABLE `#__splms_courses` ADD `sale_price` float(8,2) DEFAULT NULL AFTER `price`;

-- Create syntax for TABLE '#__splms_useritems';
CREATE TABLE IF NOT EXISTS `#__splms_useritems` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `item_id` int(11) DEFAULT '0',
  `user_id` int(11) DEFAULT NULL,
  `item_type` varchar(55) DEFAULT '',
  `published` tinyint(1) NOT NULL DEFAULT '1',
  `ordering` int(10) NOT NULL DEFAULT '0',
  `created_by` bigint(20) NOT NULL DEFAULT '0',
  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `modified_by` bigint(20) NOT NULL DEFAULT '0',
  `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `checked_out` bigint(20) NOT NULL DEFAULT '0',
  `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Create syntax for TABLE '#__splms_reviews'
CREATE TABLE IF NOT EXISTS `#__splms_reviews` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `course_id` int(11) DEFAULT NULL,
  `rating` tinyint(2) DEFAULT '0',
  `review` text,
  `published` tinyint(1) NOT NULL DEFAULT '1',
  `ordering` int(10) NOT NULL DEFAULT '0',
  `created_by` bigint(20) NOT NULL DEFAULT '0',
  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `modified_by` bigint(20) NOT NULL DEFAULT '0',
  `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `checked_out` bigint(20) NOT NULL DEFAULT '0',
  `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;