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

20 lines
625 B
PHP

<?php
require_once __DIR__ . '/../../db/config.php';
try {
$pdo = db();
$sql = "
CREATE TABLE IF NOT EXISTS certificates (
id INT AUTO_INCREMENT PRIMARY KEY,
submission_id INT NOT NULL,
certificate_code VARCHAR(255) NOT NULL UNIQUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (submission_id) REFERENCES submissions(id) ON DELETE CASCADE
);
";
$pdo->exec($sql);
echo "Migration 005_create_certificates_table executed successfully." . PHP_EOL;
} catch (PDOException $e) {
die("Could not connect to the database: " . $e->getMessage());
}