-- =====================================================
-- Add contract_status to employees (status kontrak: PKWT / PKWTT)
-- Safe: only adds column if it does not exist. No data overwrite.
-- Run in MySQL. Use your database: USE `your_sapps_db`;
-- =====================================================

SET @db = DATABASE();
SET @tbl = 'employees';
SET @col = 'contract_status';
SET @q = (SELECT COUNT(*) FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = @db AND TABLE_NAME = @tbl AND COLUMN_NAME = @col);
SET @sql = IF(@q = 0,
  'ALTER TABLE `employees` ADD COLUMN `contract_status` VARCHAR(10) NULL DEFAULT NULL COMMENT ''Status kontrak: PKWT atau PKWTT'' AFTER `contract_end_date`;',
  'SELECT ''Column contract_status already exists'' AS msg;');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
