36766-vm/db/migration_009_service_request_comments.php
Flatlogic Bot 6c14b2436f 2.0
2025-12-18 09:40:37 +00:00

22 lines
673 B
PHP

<?php
require_once __DIR__ . '/config.php';
try {
$pdo = db();
$sql = <<<SQL
CREATE TABLE IF NOT EXISTS service_request_comments (
id INT AUTO_INCREMENT PRIMARY KEY,
service_request_id INT NOT NULL,
user_id INT NOT NULL,
comment TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (service_request_id) REFERENCES service_requests(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
SQL;
$pdo->exec($sql);
echo "Migration for service_request_comments table applied successfully." . PHP_EOL;
} catch (PDOException $e) {
die("Migration failed: " . $e->getMessage());
}