CREATE TABLE `tblfree_website_blogs` (
	`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
	`staff_id` BIGINT(20) UNSIGNED NOT NULL,
	`tenant_id` BIGINT(20) UNSIGNED NOT NULL,
	`title` VARCHAR(250) NULL DEFAULT NULL,
	`slug` VARCHAR(250) NULL DEFAULT NULL,
	`sub_title` TEXT NULL DEFAULT NULL,
	`feature_image` VARCHAR(199) NULL DEFAULT NULL,
	`feature_image_url` VARCHAR(199) NULL DEFAULT NULL,
	`content` LONGTEXT NULL DEFAULT NULL,
	`status` ENUM('draft','publish','schedule_publish') NULL DEFAULT NULL,
	`view_count` INT(11) NULL DEFAULT '0',
	`published_on` DATETIME NULL DEFAULT NULL,
	`added_on` DATETIME NULL DEFAULT NULL,
	`updated_on` DATETIME NULL DEFAULT NULL,
	PRIMARY KEY (`id`),
	INDEX `BLOG INDEX` (`id`, `title`(100), `tenant_id`, `staff_id`, `slug`)
);

ALTER TABLE `tbltenant_free_website_config` ADD COLUMN `is_blog_post_enable` TINYINT(4) NULL DEFAULT '0' AFTER `offer_free_estimate`;

INSERT INTO tblplan_features (name, codename, description,type,added_on) 
VALUES('Contractor+ Free Website Blog Posts', 'cp_free_website_blog_posts', 'Contractor+ Free Website Blog Posts','restrict',UTC_TIMESTAMP());

SET @plans_features_id = LAST_INSERT_ID();
INSERT INTO tblplan_features_value (plans_id, plans_features_id, value,other_data,added_on) 
VALUES
(9,  @plans_features_id, 0,'{"outside_message":"Contractor+ Free Website Blog Posts is a ultimate feature, in order to use it Upgrade to ULTIMATE","inside_message":"Contractor+ Free Website Blog Posts is a ultimate feature, in order to use it Upgrade to ULTIMATE","tag_color":"#eb0e0e","tag_title":"ULTIMATE","link":"https:\/\/my.contractorplus.app\/","count":"0"}',UTC_TIMESTAMP()),
(10, @plans_features_id, 0,'{"outside_message":"Contractor+ Free Website Blog Posts is a ultimate feature, in order to use it Upgrade to ULTIMATE","inside_message":"Contractor+ Free Website Blog Posts is a ultimate feature, in order to use it Upgrade to ULTIMATE","tag_color":"#eb0e0e","tag_title":"ULTIMATE","link":"https:\/\/my.contractorplus.app\/","count":"0"}',UTC_TIMESTAMP()),
(11, @plans_features_id, 0,'{"outside_message":"Contractor+ Free Website Blog Posts is a ultimate feature, in order to use it Upgrade to ULTIMATE","inside_message":"Contractor+ Free Website Blog Posts is a ultimate feature, in order to use it Upgrade to ULTIMATE","tag_color":"#eb0e0e","tag_title":"ULTIMATE","link":"https:\/\/my.contractorplus.app\/","count":"0"}',UTC_TIMESTAMP()),
(12, @plans_features_id, 1,NULL,UTC_TIMESTAMP()),
(13, @plans_features_id, 0,'{"outside_message":"Contractor+ Free Website Blog Posts is a ultimate feature, in order to use it Upgrade to ULTIMATE","inside_message":"Contractor+ Free Website Blog Posts is a ultimate feature, in order to use it Upgrade to ULTIMATE","tag_color":"#eb0e0e","tag_title":"ULTIMATE","link":"https:\/\/my.contractorplus.app\/","count":"0"}',UTC_TIMESTAMP()),
(14, @plans_features_id, 0,'{"outside_message":"Contractor+ Free Website Blog Posts is a ultimate feature, in order to use it Upgrade to ULTIMATE","inside_message":"Contractor+ Free Website Blog Posts is a ultimate feature, in order to use it Upgrade to ULTIMATE","tag_color":"#eb0e0e","tag_title":"ULTIMATE","link":"https:\/\/my.contractorplus.app\/","count":"0"}',UTC_TIMESTAMP()),
(15, @plans_features_id, 1,NULL,UTC_TIMESTAMP());


INSERT INTO `tblapad_options` (`type`, `name`, `value`, `autoload`) VALUES 
('free_website_blogs_feature_files', 'allowed_file_extention', '{\"image\":[\"jpeg\",\"jpg\",\"png\",\"gif\"]}', 1),
('free_website_blogs_feature_files', 'allowed_file_size', '5120', 1);

-- ENABLE TEMPLATE 2 and 3
UPDATE `tblwebsite_preview_templates` SET `is_coming_soon`= 0 WHERE  `id` IN (2,3);

UPDATE `tblstaff` SET refresh_permissions = 1;