<?php
include 'includes/db.php';

// We need to alter the table to support detailed fields
// We will Drop the old table to ensure clean structure as we are in dev phase
$conn->query("DROP TABLE IF EXISTS job_applications");

$sql = "CREATE TABLE job_applications (
    id INT(11) NOT NULL AUTO_INCREMENT,
    first_name VARCHAR(50) NOT NULL,
    middle_name VARCHAR(50),
    last_name VARCHAR(50) NOT NULL,
    mobile VARCHAR(15) NOT NULL,
    email VARCHAR(100) NOT NULL,
    address TEXT NOT NULL,
    city VARCHAR(50) NOT NULL,
    district VARCHAR(50) NOT NULL,
    state VARCHAR(50) NOT NULL,
    resume_path VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id),
    UNIQUE KEY (email), 
    UNIQUE KEY (mobile)
)";

if ($conn->query($sql) === TRUE) {
    echo "Table 'job_applications' updated with new fields successfully.<br>";
} else {
    echo "Error updating table: " . $conn->error . "<br>";
}

echo "<a href='careers.php'>Go to Careers Page</a>";
?>
