Commit c23742ac authored by Mahmoud Aglan's avatar Mahmoud Aglan

fixhr3

parent ba5df702
...@@ -80,7 +80,7 @@ return function (Database $db): void { ...@@ -80,7 +80,7 @@ return function (Database $db): void {
if ($hasColumn('hr_salary_components', 'component_type') && !$hasColumn('hr_salary_components', 'type')) { if ($hasColumn('hr_salary_components', 'component_type') && !$hasColumn('hr_salary_components', 'type')) {
// Must drop CHECK constraint before renaming column (MySQL 3959) // Must drop CHECK constraint before renaming column (MySQL 3959)
if ($hasCheck('hr_salary_components', 'chk_hr_salary_comp_type')) { if ($hasCheck('hr_salary_components', 'chk_hr_salary_comp_type')) {
$safeAlter("ALTER TABLE `hr_salary_components` DROP CONSTRAINT `chk_hr_salary_comp_type`"); $safeAlter("ALTER TABLE `hr_salary_components` DROP CHECK `chk_hr_salary_comp_type`");
} }
$safeAlter("ALTER TABLE `hr_salary_components` CHANGE COLUMN `component_type` `type` VARCHAR(20) NOT NULL DEFAULT 'earning'"); $safeAlter("ALTER TABLE `hr_salary_components` CHANGE COLUMN `component_type` `type` VARCHAR(20) NOT NULL DEFAULT 'earning'");
$safeAlter("ALTER TABLE `hr_salary_components` ADD CONSTRAINT `chk_hr_salary_comp_type` CHECK (`type` IN ('earning', 'deduction'))"); $safeAlter("ALTER TABLE `hr_salary_components` ADD CONSTRAINT `chk_hr_salary_comp_type` CHECK (`type` IN ('earning', 'deduction'))");
...@@ -215,7 +215,7 @@ return function (Database $db): void { ...@@ -215,7 +215,7 @@ return function (Database $db): void {
if ($hasColumn('hr_holidays', 'religion_specific') && !$hasColumn('hr_holidays', 'religion')) { if ($hasColumn('hr_holidays', 'religion_specific') && !$hasColumn('hr_holidays', 'religion')) {
// Must drop CHECK constraint before renaming column (MySQL 3959) // Must drop CHECK constraint before renaming column (MySQL 3959)
if ($hasCheck('hr_holidays', 'chk_hr_holidays_religion')) { if ($hasCheck('hr_holidays', 'chk_hr_holidays_religion')) {
$safeAlter("ALTER TABLE `hr_holidays` DROP CONSTRAINT `chk_hr_holidays_religion`"); $safeAlter("ALTER TABLE `hr_holidays` DROP CHECK `chk_hr_holidays_religion`");
} }
$safeAlter("ALTER TABLE `hr_holidays` CHANGE COLUMN `religion_specific` `religion` VARCHAR(20) NULL DEFAULT NULL"); $safeAlter("ALTER TABLE `hr_holidays` CHANGE COLUMN `religion_specific` `religion` VARCHAR(20) NULL DEFAULT NULL");
echo " ✔ hr_holidays: religion_specific → religion\n"; echo " ✔ hr_holidays: religion_specific → religion\n";
...@@ -277,7 +277,7 @@ return function (Database $db): void { ...@@ -277,7 +277,7 @@ return function (Database $db): void {
if ($hasColumn('hr_payroll_components_log', 'component_type') && !$hasColumn('hr_payroll_components_log', 'type')) { if ($hasColumn('hr_payroll_components_log', 'component_type') && !$hasColumn('hr_payroll_components_log', 'type')) {
// Must drop CHECK constraint before renaming column (MySQL 3959) // Must drop CHECK constraint before renaming column (MySQL 3959)
if ($hasCheck('hr_payroll_components_log', 'chk_hr_payroll_comp_type')) { if ($hasCheck('hr_payroll_components_log', 'chk_hr_payroll_comp_type')) {
$safeAlter("ALTER TABLE `hr_payroll_components_log` DROP CONSTRAINT `chk_hr_payroll_comp_type`"); $safeAlter("ALTER TABLE `hr_payroll_components_log` DROP CHECK `chk_hr_payroll_comp_type`");
} }
$safeAlter("ALTER TABLE `hr_payroll_components_log` CHANGE COLUMN `component_type` `type` VARCHAR(20) NOT NULL"); $safeAlter("ALTER TABLE `hr_payroll_components_log` CHANGE COLUMN `component_type` `type` VARCHAR(20) NOT NULL");
$safeAlter("ALTER TABLE `hr_payroll_components_log` ADD CONSTRAINT `chk_hr_payroll_comp_type` CHECK (`type` IN ('earning', 'deduction'))"); $safeAlter("ALTER TABLE `hr_payroll_components_log` ADD CONSTRAINT `chk_hr_payroll_comp_type` CHECK (`type` IN ('earning', 'deduction'))");
...@@ -424,7 +424,7 @@ return function (Database $db): void { ...@@ -424,7 +424,7 @@ return function (Database $db): void {
$safeAlter("ALTER TABLE `hr_attendance` ADD COLUMN `is_archived` TINYINT(1) NOT NULL DEFAULT 0, ADD COLUMN `archived_at` TIMESTAMP NULL DEFAULT NULL, ADD COLUMN `archived_by` BIGINT UNSIGNED NULL"); $safeAlter("ALTER TABLE `hr_attendance` ADD COLUMN `is_archived` TINYINT(1) NOT NULL DEFAULT 0, ADD COLUMN `archived_at` TIMESTAMP NULL DEFAULT NULL, ADD COLUMN `archived_by` BIGINT UNSIGNED NULL");
} }
// Update CHECK constraint to include 'late' and 'rest_day' statuses // Update CHECK constraint to include 'late' and 'rest_day' statuses
$safeAlter("ALTER TABLE `hr_attendance` DROP CONSTRAINT `chk_hr_attendance_status`"); $safeAlter("ALTER TABLE `hr_attendance` DROP CHECK `chk_hr_attendance_status`");
$safeAlter("ALTER TABLE `hr_attendance` ADD CONSTRAINT `chk_hr_attendance_status` CHECK (`status` IN ('present', 'absent', 'late', 'leave', 'holiday', 'rest_day', 'half_day'))"); $safeAlter("ALTER TABLE `hr_attendance` ADD CONSTRAINT `chk_hr_attendance_status` CHECK (`status` IN ('present', 'absent', 'late', 'leave', 'holiday', 'rest_day', 'half_day'))");
// ─── 15. hr_leave_balances: employee_id → employee_profile_id ─── // ─── 15. hr_leave_balances: employee_id → employee_profile_id ───
...@@ -476,7 +476,7 @@ return function (Database $db): void { ...@@ -476,7 +476,7 @@ return function (Database $db): void {
if ($hasColumn('hr_employee_loans', 'amount') && !$hasColumn('hr_employee_loans', 'loan_amount')) { if ($hasColumn('hr_employee_loans', 'amount') && !$hasColumn('hr_employee_loans', 'loan_amount')) {
// Must drop CHECK constraint before renaming column (MySQL 3959) // Must drop CHECK constraint before renaming column (MySQL 3959)
if ($hasCheck('hr_employee_loans', 'chk_hr_loans_amount')) { if ($hasCheck('hr_employee_loans', 'chk_hr_loans_amount')) {
$safeAlter("ALTER TABLE `hr_employee_loans` DROP CONSTRAINT `chk_hr_loans_amount`"); $safeAlter("ALTER TABLE `hr_employee_loans` DROP CHECK `chk_hr_loans_amount`");
} }
$safeAlter("ALTER TABLE `hr_employee_loans` CHANGE COLUMN `amount` `loan_amount` DECIMAL(15,2) NOT NULL"); $safeAlter("ALTER TABLE `hr_employee_loans` CHANGE COLUMN `amount` `loan_amount` DECIMAL(15,2) NOT NULL");
$safeAlter("ALTER TABLE `hr_employee_loans` ADD CONSTRAINT `chk_hr_loans_amount` CHECK (`loan_amount` > 0)"); $safeAlter("ALTER TABLE `hr_employee_loans` ADD CONSTRAINT `chk_hr_loans_amount` CHECK (`loan_amount` > 0)");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment