23 lines
703 B
PHP
23 lines
703 B
PHP
<?php
|
|
require_once __DIR__ . '/config.php';
|
|
|
|
try {
|
|
$pdo = db();
|
|
$sql = <<<SQL
|
|
CREATE TABLE IF NOT EXISTS notifications (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
user_id INT NOT NULL,
|
|
service_request_id INT NOT NULL,
|
|
message VARCHAR(255) NOT NULL,
|
|
is_read BOOLEAN NOT NULL DEFAULT FALSE,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (service_request_id) REFERENCES service_requests(id) ON DELETE CASCADE
|
|
);
|
|
SQL;
|
|
$pdo->exec($sql);
|
|
echo "Migration for notifications table applied successfully." . PHP_EOL;
|
|
} catch (PDOException $e) {
|
|
die("Migration failed: " . $e->getMessage());
|
|
}
|