TKK_E32230273/db_notif_setup.php

25 lines
752 B
PHP

<?php
// Script to setup the notifications table
include 'koneksi.php';
try {
$sql = "CREATE TABLE IF NOT EXISTS notifications (
id INT AUTO_INCREMENT PRIMARY KEY,
icon VARCHAR(100) NOT NULL,
title VARCHAR(255) NOT NULL,
message TEXT NOT NULL,
detail TEXT NOT NULL,
time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
is_read TINYINT(1) DEFAULT 0,
is_danger TINYINT(1) DEFAULT 0,
is_deleted TINYINT(1) DEFAULT 0,
deleted_at TIMESTAMP NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
$pdo->exec($sql);
echo "Table 'notifications' created successfully.\n";
} catch(PDOException $e) {
echo "Error creating table: " . $e->getMessage() . "\n";
}
?>