37338-vm/db/migrations/017_add_group_id_to_people.php
2026-01-10 09:20:40 +00:00

19 lines
619 B
PHP

<?php
require_once(__DIR__ . '/../../db/config.php');
try {
$pdo = db();
// Add bni_group_id to people table
$stmt = $pdo->query("SHOW COLUMNS FROM people LIKE 'bni_group_id'");
if ($stmt->rowCount() == 0) {
$pdo->exec("ALTER TABLE people ADD COLUMN bni_group_id INT NULL AFTER `role`;");
$pdo->exec("ALTER TABLE people ADD CONSTRAINT fk_people_bni_group FOREIGN KEY (bni_group_id) REFERENCES bni_groups(id) ON DELETE SET NULL;");
}
echo "Migration 017 completed successfully." . PHP_EOL;
} catch (PDOException $e) {
die("Migration 017 failed: " . $e->getMessage());
}
?>