34109-vm/db/migrations/010_create_match_teams_table.php
2025-09-19 12:49:02 +00:00

23 lines
744 B
PHP

<?php
require_once __DIR__ . '/../../db/config.php';
function migrate_010_create_match_teams_table() {
$pdo = db();
try {
$pdo->exec('
CREATE TABLE IF NOT EXISTS match_teams (
match_id INT NOT NULL,
team_id INT NOT NULL,
PRIMARY KEY (match_id, team_id),
FOREIGN KEY (match_id) REFERENCES matches(id) ON DELETE CASCADE,
FOREIGN KEY (team_id) REFERENCES teams(id) ON DELETE CASCADE
);
');
echo "Migration 010 successful: Created match_teams table." . PHP_EOL;
} catch (PDOException $e) {
echo "Migration 010 failed: " . $e->getMessage() . PHP_EOL;
}
}
migrate_010_create_match_teams_table();