36884-vm/db/migrations/004_create_contracts_table.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

29 lines
860 B
PHP

<?php
require_once __DIR__ . '/../config.php';
try {
$pdo = db();
// Check if the table already exists
$stmt = $pdo->query("SHOW TABLES LIKE 'contracts'");
if ($stmt->rowCount() == 0) {
$sql = "
CREATE TABLE contracts (
id INT AUTO_INCREMENT PRIMARY KEY,
customer_name VARCHAR(255) NOT NULL,
customer_email VARCHAR(255),
customer_phone VARCHAR(50),
contract_title VARCHAR(255) NOT NULL,
start_date DATE,
end_date DATE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
";
$pdo->exec($sql);
echo "Table 'contracts' created successfully." . PHP_EOL;
} else {
echo "Table 'contracts' already exists." . PHP_EOL;
}
} catch (PDOException $e) {
die("DB ERROR: " . $e->getMessage());
}