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

14 lines
492 B
PHP

<?php
require_once __DIR__ . '/config.php';
try {
$pdo = db();
$sql = "ALTER TABLE service_requests ADD COLUMN user_id INT NOT NULL AFTER dealer_id";
$pdo->exec($sql);
$sql_fk = "ALTER TABLE service_requests ADD FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE";
$pdo->exec($sql_fk);
echo "Migration to add user_id to service_requests table applied successfully." . PHP_EOL;
} catch (PDOException $e) {
die("Migration failed: " . $e->getMessage());
}