asdlkif
This commit is contained in:
33
migration_add_is_read.php
Normal file
33
migration_add_is_read.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Migration: Add is_read column to messages table
|
||||
*/
|
||||
|
||||
// Include database connection
|
||||
require_once __DIR__ . '/../../config.php';
|
||||
|
||||
try {
|
||||
$database = DatabaseFactory::getFactory()->getConnection();
|
||||
|
||||
// Check if is_read column exists
|
||||
$sql = "SHOW COLUMNS FROM messages LIKE 'is_read'";
|
||||
$query = $database->prepare($sql);
|
||||
$query->execute();
|
||||
$result = $query->fetch();
|
||||
|
||||
if (!$result) {
|
||||
// Add is_read column
|
||||
$sql = "ALTER TABLE messages ADD COLUMN is_read TINYINT(1) NOT NULL DEFAULT 0";
|
||||
$query = $database->prepare($sql);
|
||||
$query->execute();
|
||||
|
||||
echo "Successfully added is_read column to messages table\n";
|
||||
} else {
|
||||
echo "is_read column already exists in messages table\n";
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "Error: " . $e->getMessage() . "\n";
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user