CREATE TABLE `tblcronofy_tenant_calendar` (
  `id` bigint(20) NOT NULL auto_increment Primary key,
  `tenant_id` bigint(20) NOT NULL,
  `staff_id` bigint(20) NOT NULL,
  `cronofy_account_id` varchar(200) NOT NULL,
  `cronofy_calendar_id` varchar(500) DEFAULT NULL,
  `cronofy_profile_id` varchar(200) NOT NULL,
  `cronofy_cal_json` text NOT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

ALTER TABLE `tblcalendar_events` ADD `cronofy_event_id` VARCHAR(200) NULL AFTER `updated_by`;

INSERT INTO `tblplan_features` (`name`, `codename`, `description`, `type`, `added_on`) VALUES ('Cronofy Pro Access', 'cronofy_pro_sync', 'Cronofy Pro Access', 'restrict', NOW());
SET @cronofy_pro_sync_id = LAST_INSERT_ID();
INSERT INTO `tblplan_features_value` (`plans_id`, `plans_features_id`, `value`, `added_on`) VALUES ('9', @cronofy_pro_sync_id, '0', UTC_TIMESTAMP());
INSERT INTO `tblplan_features_value` (`plans_id`, `plans_features_id`, `value`, `added_on`) VALUES ('10', @cronofy_pro_sync_id, '1', UTC_TIMESTAMP());
INSERT INTO `tblplan_features_value` (`plans_id`, `plans_features_id`, `value`, `added_on`) VALUES ('11', @cronofy_pro_sync_id, '1', UTC_TIMESTAMP());
INSERT INTO `tblplan_features_value` (`plans_id`, `plans_features_id`, `value`, `added_on`) VALUES ('12', @cronofy_pro_sync_id, '1', UTC_TIMESTAMP());


INSERT INTO `tblplan_features` (`name`, `codename`, `description`, `type`, `added_on`) VALUES ('Cronofy Ultimate Access', 'cronofy_premium_sync', 'Cronofy Ultimate Access', 'restrict', NOW());
SET @cronofy_premium_sync_id = LAST_INSERT_ID();
INSERT INTO `tblplan_features_value` (`plans_id`, `plans_features_id`, `value`, `added_on`) VALUES ('9', @cronofy_premium_sync_id, '0', UTC_TIMESTAMP());
INSERT INTO `tblplan_features_value` (`plans_id`, `plans_features_id`, `value`, `added_on`) VALUES ('10', @cronofy_premium_sync_id, '0', UTC_TIMESTAMP());
INSERT INTO `tblplan_features_value` (`plans_id`, `plans_features_id`, `value`, `added_on`) VALUES ('11', @cronofy_premium_sync_id, '0', UTC_TIMESTAMP());
INSERT INTO `tblplan_features_value` (`plans_id`, `plans_features_id`, `value`, `added_on`) VALUES ('12', @cronofy_premium_sync_id, '1', UTC_TIMESTAMP());