24 lines
871 B
PHP
24 lines
871 B
PHP
<?php
|
|
require_once __DIR__ . '/../../db/config.php';
|
|
|
|
try {
|
|
$pdo = db();
|
|
$sql = "
|
|
CREATE TABLE IF NOT EXISTS user_services (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
user_id INT NOT NULL,
|
|
service_id INT NOT NULL,
|
|
status ENUM('active', 'cancelled', 'expired') NOT NULL DEFAULT 'active',
|
|
start_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
end_date TIMESTAMP NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (service_id) REFERENCES services(id) ON DELETE CASCADE
|
|
);
|
|
";
|
|
$pdo->exec($sql);
|
|
echo "Table 'user_services' created successfully." . PHP_EOL;
|
|
} catch (PDOException $e) {
|
|
die("Could not create table 'user_services': " . $e->getMessage());
|
|
}
|