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

25 lines
869 B
PHP

<?php
require_once __DIR__ . '/config.php';
try {
$pdo = db();
$sql = <<<SQL
CREATE TABLE IF NOT EXISTS service_requests (
id INT AUTO_INCREMENT PRIMARY KEY,
dealer_id INT NOT NULL,
product_id INT NOT NULL,
serial_number VARCHAR(255) NOT NULL,
issue_description TEXT NOT NULL,
status VARCHAR(50) NOT NULL DEFAULT 'pending', -- e.g., pending, in_progress, resolved, closed
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (dealer_id) REFERENCES dealers(id) ON DELETE CASCADE,
FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE
);
SQL;
$pdo->exec($sql);
echo "Migration for service_requests table applied successfully." . PHP_EOL;
} catch (PDOException $e) {
die("Migration failed: " . $e->getMessage());
}