CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`name` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Full Name' ,
`email` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Email' ,
`password` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Password' ,
`avatar` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Avatar' ,
`company` varchar(255)  NOT NULL DEFAULT ''  COMMENT '公司, 學校' ,
`department` varchar(255)  NOT NULL DEFAULT ''  COMMENT '部門, 班級' ,
`job_number` varchar(255)  NOT NULL DEFAULT ''  COMMENT '工號, 學號' ,
`skills` longtext  NOT NULL   COMMENT '專長' ,
`descriptions` longtext  NOT NULL   COMMENT '自我介紹' ,
`phone` varchar(255)  NOT NULL DEFAULT ''   ,
`color` varchar(255)  NOT NULL DEFAULT ''  COMMENT '背景顏色' ,
`group` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Group' ,
`blocked` tinyint(4) UNSIGNED NOT NULL DEFAULT 0  COMMENT '0: normal, 1: blocked' ,
`activation` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Activation code.' ,
`reset_token` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Reset Token' ,
`last_reset` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Last Reset Time' ,
`last_login` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Last Login Time' ,
`registered` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Register Time' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Time' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_users_id`  (`id`),
INDEX `idx_users_email`  (`email`(150))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `user_socials` (
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User ID' ,
`identifier` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'User identifier name' ,
`provider` char(15)  NOT NULL DEFAULT ''  COMMENT 'Social provider' ,
INDEX `idx_user_socials_user_id`  (`user_id`),
INDEX `idx_user_socials_identifier`  (`identifier`(150))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `user_role_maps` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'ID' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User ID' ,
`role` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'teacher, internal, reseller' ,
PRIMARY KEY   (`id`),
INDEX `idx_user_role_maps_user_id`  (`user_id`),
INDEX `idx_user_role_maps_role`  (`role`(150))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `user_lesson_maps` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'ID' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User ID' ,
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
`serial_number` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '流水號' ,
`status` char(7)  NOT NULL DEFAULT ''  COMMENT 'pass, fail, process' ,
`print_date` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT '證書列印時間' ,
PRIMARY KEY   (`id`),
INDEX `idx_user_lesson_maps_user_id`  (`user_id`),
INDEX `idx_user_lesson_maps_lesson_id`  (`lesson_id`),
INDEX `idx_user_lesson_maps_status`  (`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `user_chapter_maps` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'ID' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User ID' ,
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
`chapter_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Chapter ID' ,
`status` char(7)  NOT NULL DEFAULT ''  COMMENT 'pass, fail, process' ,
PRIMARY KEY   (`id`),
INDEX `idx_user_chapter_maps_user_id`  (`user_id`),
INDEX `idx_user_chapter_maps_lesson_id`  (`lesson_id`),
INDEX `idx_user_chapter_maps_chapter_id`  (`chapter_id`),
INDEX `idx_user_chapter_maps_status`  (`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `user_section_maps` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'ID' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User ID' ,
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
`chapter_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Chapter ID' ,
`section_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Section ID' ,
`done_hours` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '已看完的時間' ,
`status` char(7)  NOT NULL DEFAULT ''  COMMENT 'pass, fail, process' ,
PRIMARY KEY   (`id`),
INDEX `idx_user_section_maps_user_id`  (`user_id`),
INDEX `idx_user_section_maps_lesson_id`  (`lesson_id`),
INDEX `idx_user_section_maps_chapter_id`  (`chapter_id`),
INDEX `idx_user_section_maps_section_id`  (`section_id`),
INDEX `idx_user_section_maps_status`  (`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `user_quiz_maps` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'ID' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User ID' ,
`quiz_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Quiz ID' ,
`status` char(7)  NOT NULL DEFAULT ''  COMMENT 'pass, fail, process, done' ,
`score` int(11)  NOT NULL DEFAULT 0  COMMENT '分數' ,
`retake` int(11)  NOT NULL DEFAULT 0  COMMENT '重測次數' ,
`score_retake` int(11)  NOT NULL DEFAULT 0  COMMENT '最高分在重測第幾次' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT '該題作答的時間' ,
PRIMARY KEY   (`id`),
INDEX `idx_user_quiz_maps_user_id`  (`user_id`),
INDEX `idx_user_quiz_maps_quiz_id`  (`quiz_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `user_question_maps` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'ID' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User ID' ,
`quiz_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Quiz ID' ,
`question_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Question ID' ,
`retake` int(11)  NOT NULL DEFAULT 0  COMMENT '重測第幾次' ,
`user_answer` longtext  NOT NULL   COMMENT '學生寫的答案' ,
`score` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '分數' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT '該題作答的時間' ,
PRIMARY KEY   (`id`),
INDEX `idx_user_question_maps_user_id`  (`user_id`),
INDEX `idx_user_question_maps_quiz_id`  (`quiz_id`),
INDEX `idx_user_question_maps_question_id`  (`question_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `user_curriculum_maps` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'ID' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User ID' ,
`curriculum_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Curriculum ID' ,
`status` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'pass, fail, process' ,
`print_date` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT '證書列印時間' ,
PRIMARY KEY   (`id`),
INDEX `idx_user_curriculum_maps_user_id`  (`user_id`),
INDEX `idx_user_curriculum_maps_curriculum_id`  (`curriculum_id`),
INDEX `idx_user_curriculum_maps_status`  (`status`(150))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `user_role_requests` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'ID' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User ID' ,
`role` char(8)  NOT NULL DEFAULT ''  COMMENT 'teacher, internal, reseller' ,
`status` char(8)  NOT NULL DEFAULT ''  COMMENT 'waiting, approved, rejected' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'   ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0   ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'   ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0   ,
`comment` longtext  NOT NULL    ,
`reviewed` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'   ,
`reviewed_by` int(11) UNSIGNED NOT NULL DEFAULT 0   ,
PRIMARY KEY   (`id`),
INDEX `idx_user_role_requests_user_id`  (`user_id`),
INDEX `idx_user_role_requests_role`  (`role`),
INDEX `idx_user_role_requests_status`  (`status`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `user_favorite_maps` (
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User ID' ,
`target_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Target ID' ,
`type` char(10)  NOT NULL DEFAULT ''  COMMENT 'Type' ,
INDEX `idx_user_favorite_maps_user_id`  (`user_id`),
INDEX `idx_user_favorite_maps_target_id`  (`target_id`),
INDEX `idx_user_favorite_maps_type`  (`type`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

SHOW FULL COLUMNS FROM `users` ;


INSERT INTO `users`
(`name`,`email`,`password`,`avatar`,`company`,`department`,`job_number`,`skills`,`descriptions`,`phone`,`color`,`group`,`blocked`,`activation`,`reset_token`,`last_reset`,`last_login`,`registered`,`modified`,`params`) VALUES 
('LYRASOFT','webadmin@lyrasoft.net','$2y$10$rdXNoLVLggNFsKMcTIjYFOKenE4DqCWR0wkZLJtTDt/C3oUXGpCwG','https://avatars0.githubusercontent.com/u/12653291','','','','','','','13','3','0','','','1000-01-01 00:00:00','1000-01-01 00:00:00','1000-01-01 00:00:00','1000-01-01 00:00:00','');

SHOW FULL COLUMNS FROM `user_role_maps` ;


INSERT INTO `user_role_maps`
(`user_id`,`role`) VALUES 
('1','internal');


INSERT INTO `user_role_maps`
(`user_id`,`role`) VALUES 
('1','reseller');


INSERT INTO `user_role_maps`
(`user_id`,`role`) VALUES 
('1','teacher');


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20160210041557','2025-03-13 04:32:00','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `categories` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`parent_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Parent ID' ,
`lft` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Left Key' ,
`rgt` int(11)  NOT NULL DEFAULT 0  COMMENT 'Right key' ,
`level` int(11)  NOT NULL DEFAULT 0  COMMENT 'Nested Level' ,
`path` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Alias Path' ,
`type` varchar(50)  NOT NULL DEFAULT ''  COMMENT 'news, page, lesson, faq, curriculum' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`subtitle` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Subtitle' ,
`alias` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Alias' ,
`image` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Main Image' ,
`color` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Color, Lesson Category的第一層Category才有' ,
`description` longtext  NOT NULL   COMMENT 'Description Text' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '0: unpublished, 1:published' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
`language` char(7)  NOT NULL DEFAULT ''  COMMENT 'Language' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_categories_alias`  (`alias`(150)),
INDEX `idx_categories_path`  (`path`(150)),
INDEX `idx_categories_lft_rgt`  (`lft`, `rgt`),
INDEX `idx_categories_language`  (`language`),
INDEX `idx_categories_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

SHOW FULL COLUMNS FROM `categories` ;


INSERT INTO `categories`
(`parent_id`,`lft`,`rgt`,`level`,`path`,`type`,`title`,`subtitle`,`alias`,`image`,`color`,`description`,`state`,`created`,`created_by`,`modified`,`modified_by`,`language`,`params`) VALUES 
('0','0','1','0','','','root','','root','','','','0','1000-01-01 00:00:00','0','1000-01-01 00:00:00','0','','');

CREATE TABLE IF NOT EXISTS `category_role_maps` (
`category_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Category ID' ,
`role` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'internal, reseller' ,
INDEX `idx_category_role_maps_category_id`  (`category_id`),
INDEX `idx_category_role_maps_role`  (`role`(150))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20160228153233','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `articles` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`category_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Category ID' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`alias` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Alias' ,
`image` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Main Image' ,
`introtext` longtext  NOT NULL   COMMENT 'Intro Text' ,
`fulltext` longtext  NOT NULL   COMMENT 'Full Text' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '0: unpublished, 1:published' ,
`ordering` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Ordering' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
`published` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Published Date' ,
`language` char(7)  NOT NULL DEFAULT ''  COMMENT 'Language' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_articles_category_id`  (`category_id`),
INDEX `idx_articles_alias`  (`alias`(150)),
INDEX `idx_articles_language`  (`language`),
INDEX `idx_articles_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20160228153300','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `tags` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`alias` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Alias' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '0: unpublished, 1:published' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
`language` char(7)  NOT NULL DEFAULT ''  COMMENT 'Language' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_tags_alias`  (`alias`(150)),
INDEX `idx_tags_language`  (`language`),
INDEX `idx_tags_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `tag_maps` (
`tag_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Tag ID' ,
`target_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Target ID' ,
`type` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Type' ,
INDEX `idx_tag_maps_tag_id`  (`tag_id`),
INDEX `idx_tag_maps_target_id`  (`target_id`),
INDEX `idx_tag_maps_type`  (`type`(150))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20160311075450','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `languages` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`title` varchar(50)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`alias` varchar(50)  NOT NULL DEFAULT ''  COMMENT 'URL Prefix' ,
`title_native` varchar(50)  NOT NULL DEFAULT ''  COMMENT 'Title Native' ,
`code` varchar(50)  NOT NULL DEFAULT ''  COMMENT 'Language Code' ,
`image` varchar(50)  NOT NULL DEFAULT ''  COMMENT 'Image' ,
`description` varchar(1024)  NOT NULL DEFAULT ''  COMMENT 'Description' ,
`metakey` longtext  NOT NULL   COMMENT 'Meta Keyword' ,
`metadesc` longtext  NOT NULL   COMMENT 'Meta Description' ,
`sitename` varchar(1024)  NOT NULL DEFAULT ''  COMMENT 'Site Name' ,
`state` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'State' ,
`ordering` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Ordering' ,
PRIMARY KEY   (`id`),
INDEX `idx_languages_code`  (`code`(50)),
INDEX `idx_languages_alias`  (`alias`(50)),
INDEX `idx_languages_ordering`  (`ordering`),
INDEX `idx_languages_image`  (`image`(50))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

SHOW FULL COLUMNS FROM `languages` ;


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('22','English (UK)','en','English (UK)','en-GB','gb','','','','','1','1');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('1','Afrikaans','af','Afrikaans','af-ZA','za','','','','','0','2');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('2','Albanian(sq-AL)','sq','Albanian','sq-AL','al','','','','','0','3');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('3','Arabic Unitag (العربية الموحدة)','ar','اللغة العربية بالكود الموحد','ar-AA','aa','','','','','0','4');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('4','Armenian (hy-AM)','hy','Հայերեն','hy-AM','am','','','','','0','5');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('5','Bahasa Indonesia','id','Bahasa Indonesia','id-ID','id','','','','','0','6');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('6','Bahasa Melayu','ms','Bahasa Melayu (MY)','ms-MY','my','','','','','0','7');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('7','Belarusian','be','Беларуская','be-BY','by','','','','','0','8');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('8','Bosnian (bs-BA)','bs','Bosanski (bs-BA)','bs-BA','ba','','','','','0','9');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('9','Bulgarian','bg','Български','bg-BG','bg','','','','','0','10');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('10','Catalan (Català - ca_ES)','ca','Català (ES)','ca-ES','es','','','','','0','11');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('11','Chinese Simplified','cn','中文（简体）','zh-CN','cn','','','','','0','12');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('12','Chinese Traditional','tw','中文(台灣．繁體)','zh-TW','tw','','','','','0','13');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('13','Croatian (hr-HR)','hr','Hrvatski (HR)','hr-HR','hr','','','','','0','14');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('14','Cymraeg (United Kingdom)','cy','Cymraeg (UK)','cy-GB','gb-wls','','','','','0','15');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('15','Czech (Czech Republic)','cs','Čeština','cs-CZ','cz','','','','','0','16');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('16','Danish (da-DK)','da','Dansk (DK)','da-DK','dk','','','','','0','17');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('17','Dari (prs-AF)','prs','فارسی (دری)','prs-AF','af','','','','','0','18');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('18','Dutch (NL)','nl-nl','Nederlands','nl-NL','nl','','','','','0','19');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('19','Dzongkha (Bhutan)','dz','Dzongkha','dz-BT','bt','','','','','0','20');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('20','English (Canada)','en-ca','English (CA)','en-CA','ca','','','','','0','21');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('21','English (en-AU)','en-au','English (AU)','en-AU','au','','','','','0','22');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('23','English (United States)','en-us','English (US)','en-US','us','','','','','0','23');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('24','Estonian','et','Eesti','et-EE','ee','','','','','0','24');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('25','Finnish (fi-FI)','fi','Finnish (FI)','fi-FI','fi','','','','','0','25');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('26','French (FR)','fr-fr','Français','fr-FR','fr','','','','','0','26');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('27','French Canadian (fr-CA)','fr-ca','Français','fr-CA','ca','','','','','0','27');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('28','Galician (Galego)','gl','Galego','gl-ES','es','','','','','0','28');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('29','German (Germany-Switzerland-Austria)','de','Deutsch','de-DE','de','','','','','0','29');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('30','Greek','el','Ελληνικά (Ελλάδα)','el-GR','gr','','','','','0','30');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('31','Hebrew (Israel)','he','עברית','he-IL','il','','','','','0','31');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('32','Hindi (India)','hi','Hindi-हिंदी (India)','hi-IN','in','','','','','0','32');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('33','Hungarian (formal)','hu','Magyar','hu-HU','hu','','','','','0','33');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('34','Irish (ga-IE)','ga','Irish (ga-IE)','ga-IE','ie','','','','','0','34');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('35','Italian (IT)','it','Italiano','it-IT','it','','','','','0','35');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('36','Japanese','ja','日本語','ja-JP','jp','','','','','0','36');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('37','Khmer (Cambodia)','km','ភាសាខ្មែរ (KH)','km-KH','kh','','','','','0','37');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('38','Korean(Republic of Korea)','ko','한국어','ko-KR','kr','','','','','0','38');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('39','Latvian (lv-LV)','lv','Latviešu','lv-LV','lv','','','','','0','39');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('40','Macedonian (MК)','mk','Македонски','mk-MK','mk','','','','','0','40');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('41','Montenegrin','srp','Crnogorski-latinica','srp-ME','me','','','','','0','41');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('42','Norsk bokmål (nb-NO)','nb','Norsk (NO)','nb-NO','no','','','','','0','42');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('43','Nynorsk (nn-NO)','nn','Nynorsk (NO)','nn-NO','no','','','','','0','43');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('44','Persian','fa','فارسی','fa-IR','ir','','','','','0','44');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('45','Polski (PL)','pl','Polski (PL)','pl-PL','pl','','','','','0','45');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('46','Portuguese (pt-PT)','pt-pt','Português (pt-PT)','pt-PT','pt','','','','','0','46');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('47','Portuguese Brasileiro (pt-BR)','pt-br','Inglês (UK)','pt-BR','br','','','','','0','47');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('48','Română (România)','ro','Română (RO)','ro-RO','ro','','','','','0','48');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('49','Russian','ru','Русский (RU)','ru-RU','ru','','','','','0','49');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('50','Serbian Cyrillic','sr-rs','Српски-ћирилица','sr-RS','rs','','','','','0','50');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('51','Serbian Latin','sr-yu','Srpski-latinica','sr-YU','rs','','','','','0','51');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('52','Sinhala (Sri Lanka)','si','සිංහල (ශ්‍රී ලංකාව)','si-LK','lk','','','','','0','52');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('53','Slovak (Slovenčina)','sk','Slovenčina','sk-SK','sk','','','','','0','53');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('54','Spanish (español)','es','Español','es-ES','es','','','','','0','54');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('55','Svenska (SE)','sv','Svenska','sv-SE','se','','','','','0','55');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('56','Swahili (East Africa)','sw','Kiswahili (Afrika Mashariki)','sw-KE','ke','','','','','0','56');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('57','Syriac (sy-IQ)','sy','Soreth (sy)','sy-IQ','iq','','','','','0','57');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('58','Tamil (India)','ta','தமிழ் (இந்தியா)','ta-IN','in','','','','','0','58');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('59','Thai (ภาษาไทย)','th','ภาษาไทย (ไทย)','th-TH','th','','','','','0','59');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('60','Turkish (Türkiye)','tr','Türkçe (TR)','tr-TR','tr','','','','','0','60');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('61','Uighur (Uyghurche)','ug','ئۇيغۇرچە','ug-CN','cn','','','','','0','61');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('62','Ukrainian (Україна)','uk','Українська (UA)','uk-UA','ua','','','','','0','62');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('63','Vietnamese (Vietnam)','vi','Tiếng Việt','vi-VN','vn','','','','','0','63');


INSERT INTO `languages`
(`id`,`title`,`alias`,`title_native`,`code`,`image`,`description`,`metakey`,`metadesc`,`sitename`,`state`,`ordering`) VALUES 
('64','Vlaams (nl-BE)','nl-be','Vlaams','nl-BE','be','','','','','0','64');


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20160311075557','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `comments` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`target_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Target ID' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User ID' ,
`type` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Type' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`content` longtext  NOT NULL   COMMENT 'Content' ,
`reply` longtext  NOT NULL   COMMENT 'Reply' ,
`reply_user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Reply User ID' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '0: unpublished, 1:published' ,
`ordering` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Ordering' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_comments_target_id`  (`target_id`),
INDEX `idx_comments_created_by`  (`created_by`),
INDEX `idx_comments_reply_user_id`  (`reply_user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20160311075605','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `modules` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`type` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Module Type' ,
`position` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Position' ,
`note` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Note' ,
`content` longtext  NOT NULL   COMMENT 'Content' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '0: unpublished, 1:published' ,
`ordering` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Ordering' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
`language` char(7)  NOT NULL DEFAULT ''  COMMENT 'Language' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_modules_position`  (`position`(150)),
INDEX `idx_modules_language`  (`language`),
INDEX `idx_modules_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20160311075645','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `lessons` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`category_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Category ID' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`sub_title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Sub Title' ,
`start_date` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Start Date' ,
`end_date` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'End Date' ,
`state` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '1 = publish, 0 = unpublish' ,
`has_board` tinyint(4) UNSIGNED NOT NULL DEFAULT 0  COMMENT '是否開啟留言板' ,
`will_learned` longtext  NOT NULL   COMMENT '我將會學到什麼' ,
`description` longtext  NOT NULL   COMMENT '課程介紹' ,
`need_prepare` longtext  NOT NULL   COMMENT '課前準備' ,
`who_need` longtext  NOT NULL   COMMENT '誰適合上這門課' ,
`standard` longtext  NOT NULL   COMMENT 'JSON - 通過標準' ,
`image` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Image' ,
`is_step_by_step` tinyint(4) UNSIGNED NOT NULL DEFAULT 0  COMMENT '是否要照順序上課' ,
`hours` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '影片時間加總' ,
`student_count` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '學生總數' ,
`rating_avg` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '平均評價' ,
`rating_statistics` longtext  NOT NULL   COMMENT 'JSON - 評價統計' ,
`related_lessons` longtext  NOT NULL   COMMENT 'JSON - 先修課程' ,
`role` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'internal, reseller' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
`approve_status` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'none, waiting, approved' ,
`approved` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Approved Date' ,
`approved_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Approved User' ,
`tutorial_done` tinyint(4) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Tutorial Done' ,
PRIMARY KEY   (`id`),
INDEX `idx_lessons_category_id`  (`category_id`),
INDEX `idx_lessons_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `lesson_announcements` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`content` longtext  NOT NULL   COMMENT 'Content' ,
`state` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '1 = publish, 0 = unpublish' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
PRIMARY KEY   (`id`),
INDEX `idx_lesson_announcements_lesson_id`  (`lesson_id`),
INDEX `idx_lesson_announcements_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `lesson_ratings` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
`rating` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Rating' ,
`comment` longtext  NOT NULL   COMMENT 'Comment' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
PRIMARY KEY   (`id`),
INDEX `idx_lesson_ratings_lesson_id`  (`lesson_id`),
INDEX `idx_lesson_ratings_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `lesson_requests` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
`status` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'waiting, approved, rejected' ,
`comment` longtext  NOT NULL   COMMENT 'Comment' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
`reviewed` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Reviewed Date' ,
`reviewed_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Reviewed User' ,
PRIMARY KEY   (`id`),
INDEX `idx_lesson_requests_lesson_id`  (`lesson_id`),
INDEX `idx_lesson_requests_status`  (`status`(150)),
INDEX `idx_lesson_requests_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `lesson_subcategory_maps` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
`category_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Category ID' ,
PRIMARY KEY   (`id`),
INDEX `idx_lesson_subcategory_maps_lesson_id`  (`lesson_id`),
INDEX `idx_lesson_subcategory_maps_category_id`  (`category_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `lesson_role_maps` (
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
`role` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'internal, reseller' ,
INDEX `idx_lesson_role_maps_lesson_id`  (`lesson_id`),
INDEX `idx_lesson_role_maps_role`  (`role`(150))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20170612065707','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `chapters` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`material` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Material' ,
`material_title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Material Title' ,
`homework_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Homework ID' ,
`test_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Test Id' ,
`ordering` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Ordering' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '0: unpublished, 1:published' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
PRIMARY KEY   (`id`),
INDEX `idx_chapters_lesson_id`  (`lesson_id`),
INDEX `idx_chapters_created_by`  (`created_by`),
INDEX `idx_chapters_homework_id`  (`homework_id`),
INDEX `idx_chapters_test_id`  (`test_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20170612065823','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `sections` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
`chapter_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Chapter ID' ,
`type` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'text, video, practice' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`description` longtext  NOT NULL   COMMENT 'Description' ,
`trial` tinyint(4) UNSIGNED NOT NULL DEFAULT 0  COMMENT '是否可以試看' ,
`content` longtext  NOT NULL   COMMENT '圖文內容' ,
`video` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Video Url' ,
`caption` varchar(255)  NOT NULL DEFAULT ''  COMMENT '字幕 Url' ,
`practice_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Quiz Id' ,
`hours` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '影片時間' ,
`hits` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '觀看人次' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '0: unpublished, 1:published' ,
`ordering` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Ordering' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
PRIMARY KEY   (`id`),
INDEX `idx_sections_lesson_id`  (`lesson_id`),
INDEX `idx_sections_chapter_id`  (`chapter_id`),
INDEX `idx_sections_type`  (`type`(150)),
INDEX `idx_sections_trial`  (`trial`),
INDEX `idx_sections_state`  (`state`),
INDEX `idx_sections_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20170612065831','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `quizzes` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
`chapter_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Chapter ID' ,
`type` char(8)  NOT NULL DEFAULT ''  COMMENT 'practice, test, homework' ,
`scoring_by` char(7)  NOT NULL DEFAULT ''  COMMENT 'system, teacher, student' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`pass_score` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '通過的基本分數' ,
`end_date` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT '作業的結束日期' ,
`scored` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '是否已經分配給批改人員？ 0: no, 1:yes' ,
`correction_date` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT '批改作業的結束日期' ,
`corrected` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '0: no, 1:yes' ,
`time_limit` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '考試的限制時間(分鐘)' ,
`retake_limit` int(11)  NOT NULL DEFAULT 0  COMMENT '可重考次數, -1 = 無限' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '0: unpublished, 1:published' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
PRIMARY KEY   (`id`),
INDEX `idx_quizzes_lesson_id`  (`lesson_id`),
INDEX `idx_quizzes_type`  (`type`),
INDEX `idx_quizzes_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20170612065916','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `questions` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
`chapter_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Chapter ID' ,
`quiz_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Quiz ID' ,
`type` char(6)  NOT NULL DEFAULT ''  COMMENT 'text, file, select' ,
`image` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Image' ,
`description` longtext  NOT NULL   COMMENT 'Description' ,
`options` longtext  NOT NULL   COMMENT 'Options' ,
`options_answer` longtext  NOT NULL   COMMENT 'Options Answer' ,
`answer` longtext  NOT NULL   COMMENT 'Answer' ,
`score` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '配分' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '0: unpublished, 1:published' ,
`ordering` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Ordering' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
PRIMARY KEY   (`id`),
INDEX `idx_questions_lesson_id`  (`lesson_id`),
INDEX `idx_questions_quiz_id`  (`quiz_id`),
INDEX `idx_questions_type`  (`type`),
INDEX `idx_questions_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20170612070015','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `curriculums` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`category_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Title' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`alias` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Alias' ,
`image` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Main Image' ,
`description` longtext  NOT NULL   COMMENT 'Description' ,
`offline_test` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '0: no, 1:yes' ,
`link` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'offline link' ,
`hours` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '影片時間加總' ,
`student_count` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '學生總數' ,
`role` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'internal, reseller' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '0: unpublished, 1:published' ,
`ordering` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Ordering' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_curriculums_category_id`  (`category_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `curriculum_lesson_maps` (
`curriculum_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Curriculum ID' ,
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
INDEX `idx_curriculum_lesson_maps_curriculum_id`  (`curriculum_id`),
INDEX `idx_curriculum_lesson_maps_lesson_id`  (`lesson_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `curriculum_role_maps` (
`curriculum_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Curriculum id' ,
`role` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'internal, reseller' ,
INDEX `idx_curriculum_role_maps_curriculum_id`  (`curriculum_id`),
INDEX `idx_curriculum_role_maps_role`  (`role`(150))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20170612070121','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `faqs` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`category_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Category' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`state` tinyint(4) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'State' ,
`content` longtext  NOT NULL   COMMENT 'Content' ,
`ordering` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Ordering' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_faqs_category_id`  (`category_id`),
INDEX `idx_faqs_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20170612070153','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `notices` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`type` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'lesson, system' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Target User' ,
`read` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Read的時間' ,
`content` longtext  NOT NULL   COMMENT 'Content' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11)  NOT NULL DEFAULT 0  COMMENT 'Author' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_notices_user_id`  (`user_id`),
INDEX `idx_notices_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20170612070236','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `messages` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`target_type` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Target Type' ,
`target_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Target' ,
`parent_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Parent Id' ,
`comment` longtext  NOT NULL   COMMENT 'comment' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`likes_count` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Likes Count' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_messages_target_type`  (`target_type`(150)),
INDEX `idx_messages_target_id`  (`target_id`),
INDEX `idx_messages_parent_id`  (`parent_id`),
INDEX `idx_messages_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `message_likes` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`message_id` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Message' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_message_likes_message_id`  (`message_id`(150)),
INDEX `idx_message_likes_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20170612070309','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `pages` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`alias` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Alias' ,
`introtext` longtext  NOT NULL   COMMENT 'Intro Text' ,
`fulltext` longtext  NOT NULL   COMMENT 'Full Text' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
`language` char(7)  NOT NULL DEFAULT ''  COMMENT 'Language' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_pages_alias`  (`alias`(150)),
INDEX `idx_pages_language`  (`language`),
INDEX `idx_pages_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20170613031500','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `configs` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`lessons` longtext  NOT NULL   COMMENT 'lessons' ,
`curriculums` longtext  NOT NULL   COMMENT 'curriculums' ,
`lesson_categories` longtext  NOT NULL   COMMENT 'lesson_categories' ,
`header` longtext  NOT NULL   COMMENT 'header' ,
`footer` longtext  NOT NULL   COMMENT 'footer' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'mega_title' ,
`logo` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Logo' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20170626083910','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `corrections` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`user_quiz_map_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '考試者的考卷id' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '考試者id' ,
`quiz_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '考卷id' ,
`score` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Score' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '是否已經有評分？ 0: process, 1:done' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '改考卷的人' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_corrections_user_quiz_map_id`  (`user_quiz_map_id`),
INDEX `idx_corrections_quiz_id`  (`quiz_id`),
INDEX `idx_corrections_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `correction_question_maps` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`correction_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Correction ID' ,
`user_question_map_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User Question Map ID' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User ID' ,
`quiz_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Quiz ID' ,
`question_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Question ID' ,
`score` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Score' ,
`comment` longtext  NOT NULL   COMMENT 'Comment' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_correction_question_maps_user_question_map_id`  (`user_question_map_id`),
INDEX `idx_correction_question_maps_quiz_id`  (`quiz_id`),
INDEX `idx_correction_question_maps_question_id`  (`question_id`),
INDEX `idx_correction_question_maps_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20170814040247','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `slideshows` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`alias` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Alias' ,
`subtitle` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Subtitle' ,
`button_text` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Button Text' ,
`url` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Button URL' ,
`image` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Main Image' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '0: unpublished, 1:published' ,
`ordering` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Ordering' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
`language` char(7)  NOT NULL DEFAULT ''  COMMENT 'Language' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_slideshows_alias`  (`alias`(150)),
INDEX `idx_slideshows_language`  (`language`),
INDEX `idx_slideshows_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20170825035254','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `sponsors` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`url` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'URL' ,
`image` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Main Image' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '0: unpublished, 1:published' ,
`ordering` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Ordering' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_sponsors_created_by`  (`created_by`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20171006060414','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `queue_jobs` (
`id` bigint(20) UNSIGNED NOT NULL  AUTO_INCREMENT  ,
`queue` varchar(255)  NOT NULL DEFAULT ''   ,
`body` longtext  NOT NULL    ,
`attempts` tinyint(4) UNSIGNED NOT NULL DEFAULT 0   ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'   ,
`visibility` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'   ,
`reserved` datetime   DEFAULT NULL   ,
PRIMARY KEY   (`id`),
INDEX `idx_queue_jobs_queue`  (`queue`(150))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20180213073059','2025-03-13 04:32:01','2025-03-13 04:32:01');


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20180727085553','2025-03-13 04:32:01','2025-03-13 04:32:01');


UPDATE `languages`
SET `state` = '1'
WHERE `alias`
IN ('cn','en');


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20180827082424','2025-03-13 04:32:01','2025-03-13 04:32:01');

CREATE TABLE IF NOT EXISTS `associations` (
`type` char(50)  NOT NULL DEFAULT ''   ,
`item_id` int(11) UNSIGNED NOT NULL DEFAULT 0   ,
`lang_code` char(7)  NOT NULL DEFAULT ''   ,
`hash` char(32)  NOT NULL DEFAULT ''   ,
INDEX `idx_associations_type`  (`type`),
INDEX `idx_associations_item_id`  (`item_id`),
INDEX `idx_associations_hash`  (`hash`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `category_langs` (
`category_id` int(11) UNSIGNED NOT NULL DEFAULT 0   ,
`code` char(7)  NOT NULL DEFAULT ''   ,
`title` varchar(255)  NOT NULL DEFAULT ''   ,
`subtitle` varchar(255)  NOT NULL DEFAULT ''   ,
INDEX `idx_category_langs_category_id`  (`category_id`),
INDEX `idx_category_langs_code`  (`code`),
UNIQUE INDEX `idx_category_langs_category_id_code`  (`category_id`, `code`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `category_langs` (category_id, `code`, title, subtitle)
SELECT id, 'zh-CN', title, subtitle FROM `categories`;;

SHOW FULL COLUMNS FROM `categories` ;

ALTER TABLE `categories` DROP `title`;

SHOW FULL COLUMNS FROM `categories` ;

ALTER TABLE `categories` DROP `subtitle`;

SHOW FULL COLUMNS FROM `categories` ;

ALTER TABLE `categories` DROP `language`;

CREATE TABLE IF NOT EXISTS `curriculum_langs` (
`curriculum_id` int(11) UNSIGNED NOT NULL DEFAULT 0   ,
`code` char(7)  NOT NULL DEFAULT ''   ,
`title` varchar(255)  NOT NULL DEFAULT ''   ,
`description` longtext  NOT NULL    ,
INDEX `idx_curriculum_langs_curriculum_id`  (`curriculum_id`),
INDEX `idx_curriculum_langs_code`  (`code`),
UNIQUE INDEX `idx_curriculum_langs_curriculum_id_code`  (`curriculum_id`, `code`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `curriculum_langs` (curriculum_id, `code`, title, description)
SELECT id, 'zh-CN', title, description FROM `curriculums`;;

SHOW FULL COLUMNS FROM `curriculums` ;

ALTER TABLE `curriculums` DROP `title`;

SHOW FULL COLUMNS FROM `curriculums` ;

ALTER TABLE `curriculums` DROP `description`;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20180831023710','2025-03-13 04:32:01','2025-03-13 04:32:02');

SHOW FULL COLUMNS FROM `faqs` ;

ALTER TABLE `faqs` ADD `language` char(7)  NOT NULL DEFAULT '' COMMENT 'Language' AFTER `modified_by` ;


UPDATE `languages`
SET `state` = '1'
WHERE `alias` = 'cn' AND `state` = '0';

SHOW FULL COLUMNS FROM `faqs` ;


UPDATE `faqs`
SET `language` = 'zh-CN'
WHERE `language` = '';


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20180928053410','2025-03-13 04:32:02','2025-03-13 04:32:02');


SELECT *
FROM `configs`
WHERE `id` = '1' LIMIT 0, 1;

SHOW FULL COLUMNS FROM `configs` ;


CREATE TABLE IF NOT EXISTS `configs` (
`type` char(50)  NOT NULL DEFAULT ''  COMMENT 'Type' ,
`subtype` char(50)  NOT NULL DEFAULT ''  COMMENT 'Sub Type' ,
`content` longtext  NOT NULL   COMMENT 'Content' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
INDEX `idx_configs_type`  (`type`),
INDEX `idx_configs_subtype`  (`subtype`),
PRIMARY KEY `idx_configs_type_subtype`  (`type`, `subtype`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20181118105051','2025-03-13 04:32:02','2025-03-13 04:32:02');

CREATE TABLE IF NOT EXISTS `recognition_histories` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
`chapter_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Chapter ID' ,
`section_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Section ID' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User ID' ,
`type` char(8)  NOT NULL DEFAULT ''   ,
`confidence` decimal(6,2) UNSIGNED NOT NULL DEFAULT 0   ,
`status` char(10)  NOT NULL DEFAULT ''  COMMENT 'success, fail' ,
`modified_confidence` decimal(6,2) UNSIGNED NOT NULL DEFAULT 0   ,
`image` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Image 上傳的圖片' ,
`verify_image` varchar(255)  NOT NULL DEFAULT ''  COMMENT '驗證圖片' ,
`verify_image_created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT '驗證圖片第一次拍照時間' ,
`verify_image_modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT '驗證圖片更改拍照的時間' ,
`verify_gender` char(6)  NOT NULL DEFAULT ''  COMMENT 'male, female' ,
`verify_age` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT '驗證年齡' ,
`verify_context` varchar(255)  NOT NULL DEFAULT ''  COMMENT '上傳或更新驗證圖片的時機' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
PRIMARY KEY   (`id`),
INDEX `idx_recognition_histories_lesson_id`  (`lesson_id`),
INDEX `idx_recognition_histories_chapter_id`  (`chapter_id`),
INDEX `idx_recognition_histories_section_id`  (`section_id`),
INDEX `idx_recognition_histories_user_id`  (`user_id`),
INDEX `idx_recognition_histories_type`  (`type`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

SHOW FULL COLUMNS FROM `users` ;

ALTER TABLE `users` ADD `verify_image` varchar(255)  NOT NULL DEFAULT '' COMMENT '驗證的圖片'  ;

SHOW FULL COLUMNS FROM `users` ;

ALTER TABLE `users` ADD `verify_image_created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00' COMMENT '第一次拍照時間'  ;

SHOW FULL COLUMNS FROM `users` ;

ALTER TABLE `users` ADD `verify_image_modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00' COMMENT '更改拍照的時間'  ;

SHOW FULL COLUMNS FROM `users` ;

ALTER TABLE `users` ADD `verify_gender` char(6)  NOT NULL DEFAULT '' COMMENT 'male, female'  ;

SHOW FULL COLUMNS FROM `users` ;

ALTER TABLE `users` ADD `verify_age` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '驗證年齡'  ;

SHOW FULL COLUMNS FROM `users` ;

ALTER TABLE `users` ADD `verify_context` varchar(255)  NOT NULL DEFAULT '' COMMENT '上傳或更新驗證圖片的時機'  ;

SHOW FULL COLUMNS FROM `user_quiz_maps` ;

ALTER TABLE `user_quiz_maps` ADD `origin_score` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '分數歸零後暫存原始分數'  ;

SHOW FULL COLUMNS FROM `user_quiz_maps` ;

ALTER TABLE `user_quiz_maps` ADD `origin_status` char(7)  NOT NULL DEFAULT '' COMMENT '分數歸零後暫存原始狀態'  ;

SHOW FULL COLUMNS FROM `user_quiz_maps` ;

ALTER TABLE `user_quiz_maps` ADD `pass_verify` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否通過照片驗證'  ;

SHOW FULL COLUMNS FROM `user_quiz_maps` ;

ALTER TABLE `user_quiz_maps` ADD `last_verify_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否通過照片驗證'  ;

SHOW FULL COLUMNS FROM `user_quiz_maps` ;

ALTER TABLE `user_quiz_maps` ADD `see_answer` tinyint(4)  NOT NULL DEFAULT 0 COMMENT '看答案'  ;

SHOW KEYS FROM `user_quiz_maps`;

ALTER TABLE `user_quiz_maps` ADD INDEX `idx_user_quiz_maps_last_verify_id`  (`last_verify_id`) ;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20181120041246','2025-03-13 04:32:02','2025-03-13 04:32:02');

SHOW FULL COLUMNS FROM `lessons` ;

ALTER TABLE `lessons` ADD `pay` tinyint(1) UNSIGNED NOT NULL DEFAULT 0  AFTER `state` ;

SHOW FULL COLUMNS FROM `lessons` ;

ALTER TABLE `lessons` ADD `price` decimal(20,6) UNSIGNED NOT NULL DEFAULT 0  AFTER `pay` ;

SHOW FULL COLUMNS FROM `lessons` ;

ALTER TABLE `lessons` ADD `in_special` tinyint(1) UNSIGNED NOT NULL DEFAULT 0  AFTER `price` ;

SHOW FULL COLUMNS FROM `lessons` ;

ALTER TABLE `lessons` ADD `special_price` decimal(20,6) UNSIGNED NOT NULL DEFAULT 0  AFTER `in_special` ;

SHOW FULL COLUMNS FROM `lessons` ;

ALTER TABLE `lessons` ADD `show_student_count` char(10)  NOT NULL DEFAULT '' COMMENT 'real,custom,text' AFTER `student_count` ;

SHOW FULL COLUMNS FROM `lessons` ;

ALTER TABLE `lessons` ADD `student_count_value` varchar(255)  NOT NULL DEFAULT ''  AFTER `show_student_count` ;

CREATE TABLE IF NOT EXISTS `orders` (
`id` int(10) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User ID' ,
`invoice_no` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Invoice No' ,
`state` char(10)  NOT NULL DEFAULT ''  COMMENT 'State' ,
`name` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Name' ,
`email` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Email' ,
`phone` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Phone' ,
`total` decimal(20, 6) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Total' ,
`invoice_type` char(8)  NOT NULL DEFAULT ''  COMMENT 'Invoice Type' ,
`invoice_title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Invoice Title' ,
`invoice_address` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Invoice Address' ,
`invoice_zip` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Invoice Zip' ,
`invoice_vat` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Invoice Vat' ,
`payment` char(10)  NOT NULL DEFAULT ''  COMMENT 'Payment' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
`payment_params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_orders_user_id`  (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `order_items` (
`id` int(10) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`order_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Order ID' ,
`lesson_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Lesson ID' ,
`price` decimal(20,6) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Price' ,
`total` decimal(20,6) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Total' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
PRIMARY KEY   (`id`),
INDEX `idx_order_items_order_id`  (`order_id`),
INDEX `idx_order_items_lesson_id`  (`lesson_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `order_total` (
`id` int(10) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`order_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Order ID' ,
`discount_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Discount ID' ,
`type` char(20)  NOT NULL DEFAULT ''  COMMENT 'Type' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`code` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Code' ,
`value` decimal(20,6)  NOT NULL DEFAULT 0  COMMENT 'Value' ,
`ordering` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Ordering' ,
`protect` tinyint(1) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Protect' ,
`params` longtext  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_order_total_order_id`  (`order_id`),
INDEX `idx_order_total_discount_id`  (`discount_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

SHOW FULL COLUMNS FROM `users` ;

ALTER TABLE `users` ADD `receive_mail` tinyint(1) UNSIGNED NOT NULL DEFAULT 0  AFTER `activation` ;

SHOW FULL COLUMNS FROM `users` ;


UPDATE `users`
SET `receive_mail` = '1'
WHERE `group`
IN ('2','3');


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20181120104343','2025-03-13 04:32:02','2025-03-13 04:32:02');

CREATE TABLE IF NOT EXISTS `discounts` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`type` char(10)  NOT NULL DEFAULT ''  COMMENT 'Type' ,
`code` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Code' ,
`title` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Title' ,
`description` longtext  NOT NULL   COMMENT 'Description' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT 'State' ,
`ordering` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Ordering' ,
`quantity` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Quantity' ,
`times_per_user` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Times Per User' ,
`method` char(10)  NOT NULL DEFAULT ''  COMMENT 'Method' ,
`offset` decimal(20, 6)  NOT NULL DEFAULT 0  COMMENT 'Offset' ,
`start_date` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Start Date' ,
`end_date` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'End Date' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
PRIMARY KEY   (`id`),
INDEX `idx_discounts_code`  (`code`(150)),
INDEX `idx_discounts_start_date`  (`start_date`),
INDEX `idx_discounts_end_date`  (`end_date`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `discount_usage` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User Id' ,
`order_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Order Id' ,
`discount_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Discount Id' ,
`type` char(10)  NOT NULL DEFAULT ''  COMMENT 'Type' ,
`code` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Code' ,
`method` char(10)  NOT NULL DEFAULT ''  COMMENT 'Method' ,
`price` decimal(20, 6)  NOT NULL DEFAULT 0  COMMENT 'Price' ,
`used_at` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'   ,
PRIMARY KEY   (`id`),
INDEX `idx_discount_usage_user_id`  (`user_id`),
INDEX `idx_discount_usage_order_id`  (`order_id`),
INDEX `idx_discount_usage_discount_id`  (`discount_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `discount_rules` (
`discount_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Discount Id' ,
`type` varchar(30)  NOT NULL DEFAULT ''  COMMENT 'Type' ,
`target_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Target Id' ,
`extra` longtext  NOT NULL   COMMENT 'Extra' ,
PRIMARY KEY `idx_discount_rules_discount_id_type_target_id`  (`discount_id`, `type`, `target_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20181123034613','2025-03-13 04:32:02','2025-03-13 04:32:02');

SHOW FULL COLUMNS FROM `lessons` ;

ALTER TABLE `lessons` ADD `message_count` int(11) UNSIGNED NOT NULL DEFAULT 0  AFTER `student_count` ;

SHOW FULL COLUMNS FROM `sections` ;

ALTER TABLE `sections` ADD `message_count` int(11) UNSIGNED NOT NULL DEFAULT 0  AFTER `hours` ;

SHOW FULL COLUMNS FROM `chapters` ;

ALTER TABLE `chapters` ADD `message_count` int(11) UNSIGNED NOT NULL DEFAULT 0  AFTER `state` ;

SHOW FULL COLUMNS FROM `quizzes` ;

ALTER TABLE `quizzes` ADD `message_count` int(11) UNSIGNED NOT NULL DEFAULT 0  AFTER `state` ;


SELECT id
FROM `sections`;


SELECT id
FROM `quizzes`;


SELECT id
FROM `chapters`;


SELECT id
FROM `lessons`;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20181126132703','2025-03-13 04:32:02','2025-03-13 04:32:02');

CREATE TABLE IF NOT EXISTS `subscriptions` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT  ,
`type` varchar(255)  NOT NULL DEFAULT ''   ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0   ,
`target_id` int(11) UNSIGNED NOT NULL DEFAULT 0   ,
PRIMARY KEY   (`id`),
INDEX `idx_subscriptions_type_user_id_target_id`  (`type`(150), `user_id`, `target_id`),
INDEX `idx_subscriptions_type`  (`type`(150)),
INDEX `idx_subscriptions_user_id`  (`user_id`),
INDEX `idx_subscriptions_target_id`  (`target_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20181208165642','2025-03-13 04:32:02','2025-03-13 04:32:02');

SHOW FULL COLUMNS FROM `lessons` ;

ALTER TABLE `lessons` MODIFY `hours` float(10,6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '影片時間加總'  ;

SHOW FULL COLUMNS FROM `sections` ;

ALTER TABLE `sections` MODIFY `hours` float(10,6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '影片時間'  ;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20190114092350','2025-03-13 04:32:02','2025-03-13 04:32:02');

SHOW FULL COLUMNS FROM `users` ;

ALTER TABLE `users` ADD `face_attributes` longtext  NOT NULL   AFTER `verify_context` ;

SHOW FULL COLUMNS FROM `recognition_histories` ;

ALTER TABLE `recognition_histories` ADD `face_attributes` longtext  NOT NULL   AFTER `verify_context` ;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20190123180601','2025-03-13 04:32:02','2025-03-13 04:32:02');

SHOW FULL COLUMNS FROM `lessons` ;

ALTER TABLE `lessons` ADD `custom_hours` float(10,2) UNSIGNED NOT NULL DEFAULT 0 COMMENT '自訂時數' After `hours` ;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20190212035052','2025-03-13 04:32:02','2025-03-13 04:32:02');

SHOW FULL COLUMNS FROM `users` ;

ALTER TABLE `users` ADD `experience` text  NOT NULL  COMMENT '教學經驗' After `descriptions` ;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20190221070245','2025-03-13 04:32:02','2025-03-13 04:32:02');

SHOW FULL COLUMNS FROM `sections` ;

ALTER TABLE `sections` ADD `target_id` int(11) UNSIGNED NOT NULL DEFAULT 0  AFTER `chapter_id` ;

SHOW FULL COLUMNS FROM `sections` ;

ALTER TABLE `sections` ADD `material` varchar(255)  NOT NULL DEFAULT ''  AFTER `video` ;

SHOW KEYS FROM `sections`;

ALTER TABLE `sections` ADD INDEX `idx_sections_target_id`  (`target_id`) ;

SHOW KEYS FROM `sections`;

ALTER TABLE `sections` ADD INDEX `idx_sections_type_target_id`  (`type`(50), `target_id`) ;

SHOW FULL COLUMNS FROM `quizzes` ;

ALTER TABLE `quizzes` ADD `section_id` int(11) UNSIGNED NOT NULL DEFAULT 0  AFTER `chapter_id` ;

SHOW KEYS FROM `quizzes`;

ALTER TABLE `quizzes` ADD INDEX `idx_quizzes_section_id`  (`section_id`) ;


SELECT *
FROM quizzes
WHERE type != 'practice';


UPDATE sections
SET target_id = practice_id
WHERE type = 'practice';


UPDATE quizzes AS quiz
INNER JOIN sections AS section ON section.target_id = quiz.id AND quiz.type = 'practice'
SET quiz.section_id = section.id;


SELECT *
FROM chapters;

SHOW FULL COLUMNS FROM `chapters` ;

ALTER TABLE `chapters` DROP `material`;

SHOW FULL COLUMNS FROM `chapters` ;

ALTER TABLE `chapters` DROP `material_title`;

SHOW FULL COLUMNS FROM `chapters` ;

ALTER TABLE `chapters` DROP `homework_id`;

SHOW FULL COLUMNS FROM `chapters` ;

ALTER TABLE `chapters` DROP `test_id`;

SHOW FULL COLUMNS FROM `sections` ;

ALTER TABLE `sections` DROP `practice_id`;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20190221092602','2025-03-13 04:32:02','2025-03-13 04:32:03');

CREATE TABLE IF NOT EXISTS `contacts` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`subject` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Subject' ,
`email` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Email' ,
`name` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Sender Name' ,
`url` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'URL' ,
`phone` varchar(255)  NOT NULL DEFAULT ''  COMMENT 'Phone' ,
`content` longtext  NOT NULL   COMMENT 'Content' ,
`details` text  NOT NULL   COMMENT 'Details JSON' ,
`state` tinyint(4)  NOT NULL DEFAULT 0  COMMENT '-1:cancel, 0:pending, 1:handling, 2:done' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
`created_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Author' ,
`modified` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Modified Date' ,
`modified_by` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'Modified User' ,
`params` text  NOT NULL   COMMENT 'Params' ,
PRIMARY KEY   (`id`),
INDEX `idx_contacts_email`  (`email`(150)),
INDEX `idx_contacts_phone`  (`phone`(150)),
INDEX `idx_contacts_name`  (`name`(150))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20190225171940','2025-03-13 04:32:03','2025-03-13 04:32:03');

SHOW FULL COLUMNS FROM `curriculums` ;

ALTER TABLE `curriculums` DROP `hours`;

SHOW FULL COLUMNS FROM `curriculums` ;

ALTER TABLE `curriculums` DROP `student_count`;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20190326070528','2025-03-13 04:32:03','2025-03-13 04:32:03');

SHOW FULL COLUMNS FROM `users` ;

ALTER TABLE `users` ADD `position` varchar(255)  NOT NULL DEFAULT ''  AFTER `face_attributes` ;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20191226071926','2025-03-13 04:32:03','2025-03-13 04:32:03');

SHOW FULL COLUMNS FROM `user_lesson_maps` ;

ALTER TABLE `user_lesson_maps` ADD `dwell_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Dwell Time (s)'  ;

SHOW FULL COLUMNS FROM `user_chapter_maps` ;

ALTER TABLE `user_chapter_maps` ADD `dwell_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Dwell Time (s)'  ;

SHOW FULL COLUMNS FROM `user_section_maps` ;

ALTER TABLE `user_section_maps` ADD `dwell_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Dwell Time (s)'  ;

SHOW FULL COLUMNS FROM `user_quiz_maps` ;

ALTER TABLE `user_quiz_maps` ADD `dwell_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Dwell Time (s)'  ;

SHOW FULL COLUMNS FROM `messages` ;

ALTER TABLE `messages` ADD `overhead` tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'OverHead' after `likes_count` ;

SHOW FULL COLUMNS FROM `user_lesson_maps` ;

ALTER TABLE `user_lesson_maps` ADD `mute` tinyint(4) UNSIGNED NOT NULL DEFAULT 0  AFTER `status` ;

SHOW FULL COLUMNS FROM `sections` ;

ALTER TABLE `sections` ADD `src` varchar(255)  NOT NULL DEFAULT ''  AFTER `material` ;

SHOW FULL COLUMNS FROM `sections` ;

ALTER TABLE `sections` ADD `preview` varchar(255)  NOT NULL DEFAULT ''  AFTER `src` ;

SHOW FULL COLUMNS FROM `sections` ;

ALTER TABLE `sections` ADD `filename` varchar(255)  NOT NULL DEFAULT ''  AFTER `preview` ;

SHOW FULL COLUMNS FROM `sections` ;

ALTER TABLE `sections` ADD `ext` char(15)  NOT NULL DEFAULT ''  AFTER `filename` ;


SELECT *
FROM sections
WHERE `type` 
IN('video','material');

SHOW FULL COLUMNS FROM `sections` ;

ALTER TABLE `sections` DROP `video`;

SHOW FULL COLUMNS FROM `sections` ;

ALTER TABLE `sections` DROP `material`;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20200416031416','2025-03-13 04:32:03','2025-03-13 04:32:04');

SHOW FULL COLUMNS FROM `users` ;

ALTER TABLE `users` ADD `no` varchar(255)  NOT NULL DEFAULT ''  AFTER `id` ;

SHOW FULL COLUMNS FROM `users` ;

ALTER TABLE `users` ADD `serial` varchar(255)  NOT NULL DEFAULT ''  AFTER `no` ;

SHOW KEYS FROM `users`;

ALTER TABLE `users` ADD INDEX `idx_users_no`  (`no`(150)) ;

SHOW KEYS FROM `users`;

ALTER TABLE `users` ADD INDEX `idx_users_serial`  (`serial`(150)) ;


SELECT *
FROM users;


SELECT MAX(serial) AS serial
FROM users
WHERE YEAR(registered) = '1000';


SELECT *
FROM `configs`
WHERE `type` = 'core' LIMIT 0, 1;

SHOW FULL COLUMNS FROM `configs` ;

SHOW FULL COLUMNS FROM `users` ;


UPDATE `users`
SET `no` = 'DVA00000001'
	, `serial` = '00000001'
WHERE `id` = '1';


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20200613162331','2025-03-13 04:32:04','2025-03-13 04:32:04');

SHOW FULL COLUMNS FROM `categories` ;

ALTER TABLE `categories` MODIFY `lft` int(11)  NOT NULL DEFAULT 0   ;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20200720053934','2025-03-13 04:32:04','2025-03-13 04:32:04');

SHOW FULL COLUMNS FROM `lessons` ;

ALTER TABLE `lessons` ADD `params` longtext  NOT NULL    ;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20200915095202','2025-03-13 04:32:04','2025-03-13 04:32:04');

SHOW FULL COLUMNS FROM `user_favorite_maps` ;

ALTER TABLE `user_favorite_maps` ADD `created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00' COMMENT 'created'  ;

SHOW FULL COLUMNS FROM `user_lesson_maps` ;

ALTER TABLE `user_lesson_maps` ADD `created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00' COMMENT 'created'  ;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20200916070555','2025-03-13 04:32:04','2025-03-13 04:32:04');

SHOW FULL COLUMNS FROM `sections` ;

ALTER TABLE `sections` ADD `length` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'length' after `hours` ;


SELECT *
FROM `sections`
WHERE `type` = 'video';


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20200923042511','2025-03-13 04:32:04','2025-03-13 04:32:04');

CREATE TABLE IF NOT EXISTS `login_logs` (
`id` int(11) UNSIGNED NOT NULL  AUTO_INCREMENT COMMENT 'Primary Key' ,
`user_id` int(11) UNSIGNED NOT NULL DEFAULT 0  COMMENT 'User Id' ,
`created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  COMMENT 'Created Date' ,
PRIMARY KEY   (`id`),
INDEX `idx_login_logs_user_id`  (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20201007074423','2025-03-13 04:32:04','2025-03-13 04:32:04');

SHOW FULL COLUMNS FROM `user_lesson_maps` ;

ALTER TABLE `user_lesson_maps` ADD `count` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '上課次數' after `dwell_time` ;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20201020075429','2025-03-13 04:32:04','2025-03-13 04:32:04');

SHOW FULL COLUMNS FROM `user_question_maps` ;

ALTER TABLE `user_question_maps` ADD `dwell_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '作答時間' after `score` ;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20201029073923','2025-03-13 04:32:04','2025-03-13 04:32:04');

SHOW FULL COLUMNS FROM `subscriptions` ;

ALTER TABLE `subscriptions` ADD `created` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00'  After `target_id` ;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20201117080055','2025-03-13 04:32:04','2025-03-13 04:32:04');


SELECT *
FROM `lessons`;

SHOW FULL COLUMNS FROM `lessons` ;

ALTER TABLE `lessons` MODIFY `student_count_value` int(11)   DEFAULT 0   ;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20210701075811','2025-03-13 04:32:04','2025-03-13 04:32:04');

SHOW FULL COLUMNS FROM `user_lesson_maps` ;

ALTER TABLE `user_lesson_maps` ADD `last_attend` datetime  NOT NULL DEFAULT '1000-01-01 00:00:00' COMMENT '最後觀看時間' after `count` ;


INSERT INTO `migration_log`
(`version`,`start_time`,`end_time`) VALUES 
('20230412065248','2025-03-13 04:32:04','2025-03-13 04:32:04');

