22 lines
658 B
PHP
22 lines
658 B
PHP
<?php
|
|
require_once __DIR__ . '/../config.php';
|
|
|
|
try {
|
|
$pdo = db();
|
|
$sql = "
|
|
CREATE TABLE IF NOT EXISTS match_votes (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
match_id INT NOT NULL,
|
|
user_id INT NOT NULL,
|
|
vote ENUM('yes', 'no') NOT NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (match_id) REFERENCES matches(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
) ENGINE=INNODB;
|
|
";
|
|
$pdo->exec($sql);
|
|
echo "Table 'match_votes' created successfully." . PHP_EOL;
|
|
} catch (PDOException $e) {
|
|
die("DB ERROR: " . $e->getMessage());
|
|
}
|