INSERT INTO `rq_resource_permissions` (`resource_permissions_id`, `resource_name`, `can_read`, `can_add`, `can_edit`, `can_delete`, `status`, `last_updated`) VALUES (NULL, 'phonics_worksheet', '3,1,2,4,5,6', '1,2,4', '1,2,4', '1,2,4', '1', '2018-10-06 00:00:00');

ALTER TABLE `rq_phonics` ADD `is_worksheet` INT(10) NOT NULL AFTER `gameqz_5`, ADD `worksheet_doc` VARCHAR(255) NOT NULL AFTER `is_worksheet`; 
ALTER TABLE `rq_phonics` ADD `worksheet_doc_original` VARCHAR(255) NOT NULL AFTER `worksheet_doc`; 

CREATE TABLE `rq_phonics_worksheet_result` ( 
    `id` INT NOT NULL AUTO_INCREMENT , 
    `phonics_id` INT NOT NULL , 
    `user_id` INT NOT NULL , 
    `worksheet_page_number` INT NOT NULL , 
    `worksheet_image` LONGTEXT NOT NULL , 
    `created_at` TIMESTAMP NOT NULL , 
    `updated_at` DATETIME on update CURRENT_TIMESTAMP NOT NULL 
, PRIMARY KEY (`id`)) ENGINE = InnoDB;

ALTER TABLE `rq_phonics` ADD `allow_play_video` VARCHAR(100) NOT NULL AFTER `worksheet_doc_original`;

ALTER TABLE `rq_phonics` ADD `worksheet_status` ENUM('','Started','Submitted') NULL AFTER `allow_play_video`;

CREATE TABLE `rq_phonics_worksheet_result_status` ( `id` INT NOT NULL AUTO_INCREMENT , `phonics_id` INT NOT NULL , `user_id` INT NOT NULL , `worksheet_status` ENUM('','Started','Submitted') NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;

ALTER TABLE `rq_phonics_worksheet_result_status` ADD `last_updated` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `worksheet_status`; 

ALTER TABLE `rq_phonics` CHANGE `is_worksheet` `is_worksheet` INT(10) NULL DEFAULT NULL, CHANGE `worksheet_doc` `worksheet_doc` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, CHANGE `worksheet_doc_original` `worksheet_doc_original` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, CHANGE `allow_play_video` `allow_play_video` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, CHANGE `worksheet_status` `worksheet_status` ENUM('','Started','Submitted') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;