36398-vm/db/migrate_leave_requests.php
2025-11-28 03:31:58 +00:00

21 lines
664 B
PHP

<?php
require_once 'config.php';
try {
$pdo = db();
$sql = "CREATE TABLE IF NOT EXISTS leave_requests (
id INT AUTO_INCREMENT PRIMARY KEY,
employee_id INT NOT NULL,
start_date DATE NOT NULL,
end_date DATE NOT NULL,
reason TEXT,
status ENUM('pending', 'approved', 'rejected') DEFAULT 'pending',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (employee_id) REFERENCES users(id) ON DELETE CASCADE
);";
$pdo->exec($sql);
echo "Table 'leave_requests' created successfully." . PHP_EOL;
} catch (PDOException $e) {
die("Error creating table: " . $e->getMessage());
}
?>