34915-vm/db/migrations/003_create_submissions_table.php
2025-10-14 07:40:18 +00:00

22 lines
726 B
PHP

<?php
require_once __DIR__ . '/../../db/config.php';
try {
$pdo = db();
$sql = "
CREATE TABLE IF NOT EXISTS submissions (
id INT AUTO_INCREMENT PRIMARY KEY,
competition_id INT NOT NULL,
user_id INT(11) UNSIGNED NOT NULL,
file_path VARCHAR(255) NOT NULL,
uploaded_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (competition_id) REFERENCES competitions(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
";
$pdo->exec($sql);
echo "Migration 003_create_submissions_table executed successfully." . PHP_EOL;
} catch (PDOException $e) {
die("Could not connect to the database: " . $e->getMessage());
}