-- Smart School DB
-- Version 7.0.0
-- https://smart-school.in
-- https://qdocs.net
-- New tables added: 0

-- --------------------------------------------------------

ALTER TABLE `sch_settings` ADD `scan_code_type` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'barcode' AFTER `offline_bank_payment_instruction`;


ALTER TABLE `attendence_type` ADD `long_lang_name` VARCHAR(250) NULL DEFAULT NULL AFTER `key_value`;
ALTER TABLE `attendence_type` ADD `long_name_style` VARCHAR(250) NULL DEFAULT NULL AFTER `long_lang_name`;
ALTER TABLE `attendence_type` ADD `for_qr_attendance` INT NOT NULL DEFAULT '1' AFTER `is_active`;

 
UPDATE `attendence_type` SET `long_lang_name` = 'present' WHERE `attendence_type`.`id` = 1;
UPDATE `attendence_type` SET `long_lang_name` = 'late_with_excuse' WHERE `attendence_type`.`id` = 2;
UPDATE `attendence_type` SET `long_lang_name` = 'late' WHERE `attendence_type`.`id` = 3;
UPDATE `attendence_type` SET `long_lang_name` = 'absent' WHERE `attendence_type`.`id` = 4;
UPDATE `attendence_type` SET `long_lang_name` = 'holiday' WHERE `attendence_type`.`id` = 5;
UPDATE `attendence_type` SET `long_lang_name` = 'half_day' WHERE `attendence_type`.`id` = 6;


UPDATE `attendence_type` SET `long_name_style` = 'label label-success' WHERE `attendence_type`.`id` = 1;
UPDATE `attendence_type` SET `long_name_style` = 'label label-warning text-dark' WHERE `attendence_type`.`id` = 2;
UPDATE `attendence_type` SET `long_name_style` = 'label label-warning text-dark' WHERE `attendence_type`.`id` = 3;
UPDATE `attendence_type` SET `long_name_style` = 'label label-danger' WHERE `attendence_type`.`id` = 4;
UPDATE `attendence_type` SET `long_name_style` = 'label label-info' WHERE `attendence_type`.`id` = 5;
UPDATE `attendence_type` SET `long_name_style` = 'label label-warning text-dark' WHERE `attendence_type`.`id` = 6;


UPDATE `attendence_type` SET `for_qr_attendance` = '0' WHERE `attendence_type`.`id` = 2;
UPDATE `attendence_type` SET `for_qr_attendance` = '0' WHERE `attendence_type`.`id` = 4;
UPDATE `attendence_type` SET `for_qr_attendance` = '0' WHERE `attendence_type`.`id` = 5;


ALTER TABLE `staff_attendance_type` ADD `for_qr_attendance` INT NOT NULL DEFAULT '1' AFTER `is_active`;
ALTER TABLE `staff_attendance_type` ADD `long_lang_name` VARCHAR(250) NULL DEFAULT NULL AFTER `for_qr_attendance`;
ALTER TABLE `staff_attendance_type` ADD `long_name_style` VARCHAR(250) NULL DEFAULT NULL AFTER `long_lang_name`;


UPDATE `staff_attendance_type` SET `long_lang_name` = 'present' WHERE `staff_attendance_type`.`id` = 1;
UPDATE `staff_attendance_type` SET `long_lang_name` = 'late' WHERE `staff_attendance_type`.`id` = 2;
UPDATE `staff_attendance_type` SET `long_lang_name` = 'absent' WHERE `staff_attendance_type`.`id` = 3;
UPDATE `staff_attendance_type` SET `long_lang_name` = 'half_day' WHERE `staff_attendance_type`.`id` = 4;
UPDATE `staff_attendance_type` SET `long_lang_name` = 'holiday' WHERE `staff_attendance_type`.`id` = 5;


UPDATE `staff_attendance_type` SET `long_name_style` = 'label label-success' WHERE `staff_attendance_type`.`id` = 1;
UPDATE `staff_attendance_type` SET `long_name_style` = 'label label-warning' WHERE `staff_attendance_type`.`id` = 2;
UPDATE `staff_attendance_type` SET `long_name_style` = 'label label-danger' WHERE `staff_attendance_type`.`id` = 3;
UPDATE `staff_attendance_type` SET `long_name_style` = 'label label-info' WHERE `staff_attendance_type`.`id` = 4;
UPDATE `staff_attendance_type` SET `long_name_style` = 'label label-warning text-dark' WHERE `staff_attendance_type`.`id` = 5;


UPDATE `staff_attendance_type` SET `for_qr_attendance` = '0' WHERE `staff_attendance_type`.`id` = 3;
UPDATE `staff_attendance_type` SET `for_qr_attendance` = '0' WHERE `staff_attendance_type`.`id` = 5;


ALTER TABLE `staff_attendance` ADD `qrcode_attendance` INT NOT NULL DEFAULT '0' AFTER `staff_attendance_type_id`;


ALTER TABLE `staff_attendance` ADD `user_agent` VARCHAR(250) NULL DEFAULT NULL AFTER `biometric_device_data`;


ALTER TABLE `student_attendences` ADD `qrcode_attendance` INT NOT NULL DEFAULT '0' AFTER `biometric_attendence`;


ALTER TABLE `student_attendences` ADD `user_agent` VARCHAR(250) NULL DEFAULT NULL AFTER `biometric_device_data`;
 

ALTER TABLE `online_admissions`
  ADD KEY `idx_reference_no` (`reference_no`),
  ADD KEY `idx_mobileno` (`mobileno`);


ALTER TABLE `online_admission_custom_field_value`
  ADD KEY `idx_belong_table_id` (`belong_table_id`),
  ADD KEY `idx_field_value` (`field_value`(200));


ALTER TABLE `students`
  ADD KEY `idx_admission_no` (`admission_no`),
  ADD KEY `idx_roll_no` (`roll_no`),
  ADD KEY `idx_mobileno` (`mobileno`),
  ADD KEY `idx_email` (`email`),
  ADD KEY `idx_firstname` (`firstname`);


ALTER TABLE `student_doc`
  ADD KEY `idx_student_id` (`student_id`);


ALTER TABLE `subjects`
  ADD KEY `idx_name` (`name`),
  ADD KEY `idx_code` (`code`);


ALTER TABLE `upload_contents`
  ADD KEY `idx_file_type` (`file_type`);


ALTER TABLE `vehicles`
  ADD KEY `idx_vehicle_no` (`vehicle_no`);


ALTER TABLE `video_tutorial`
  ADD KEY `idx_title` (`title`);