37332-vm/db/migrations/005_create_tickets_table.php
Flatlogic Bot 298521e30e bb
2026-01-09 01:55:06 +00:00

19 lines
585 B
PHP

<?php
require_once __DIR__ . '/../../db/config.php';
try {
$conn = db();
$sql = "CREATE TABLE IF NOT EXISTS tickets (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
event_id INT NOT NULL,
purchase_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (event_id) REFERENCES events(id)
)";
$conn->exec($sql);
echo "Migration successful: 'tickets' table created." . PHP_EOL;
} catch (PDOException $e) {
echo "Migration failed: " . $e->getMessage() . PHP_EOL;
}