36884-vm/db/migrations/005_add_contract_id_to_service_requests.php
Flatlogic Bot b4ffcec973 feat: Implement engineer and contract management
- Add Field Engineer Management feature, allowing creation, and assignment of engineers to service requests.

- Add Service Contract/AMC Management feature, allowing creation of contracts and linking them to service requests.

- Update admin panel to manage engineers and contracts.

- Update service request form to include contract selection.
2025-12-12 09:47:39 +00:00

25 lines
760 B
PHP

<?php
require_once __DIR__ . '/../config.php';
try {
$pdo = db();
// Check if the column already exists
$stmt = $pdo->query("SHOW COLUMNS FROM `service_requests` LIKE 'contract_id'");
if ($stmt->rowCount() == 0) {
$sql = "
ALTER TABLE service_requests
ADD COLUMN contract_id INT NULL,
ADD CONSTRAINT fk_contract_id
FOREIGN KEY (contract_id)
REFERENCES contracts(id)
ON DELETE SET NULL;
";
$pdo->exec($sql);
echo "Column 'contract_id' added to 'service_requests' table." . PHP_EOL;
} else {
echo "Column 'contract_id' already exists in 'service_requests' table." . PHP_EOL;
}
} catch (PDOException $e) {
die("DB ERROR: " . $e->getMessage());
}