Current directory: /home/klas4s23/domains/585455.klas4s23.mid-ica.nl/public_html/Gastenboek/uploads
<?php
/**
* Database migration to add recurring task columns
* Run this script once to update your existing database
*/
require_once 'includes/classes/Databases.php';
try {
$db = Database::getInstance();
$pdo = $db->getPDO();
echo "Starting database migration for recurring task columns...\n";
// Check if columns already exist
$stmt = $pdo->query("SHOW COLUMNS FROM tasks LIKE 'is_recurring'");
$isRecurringExists = $stmt->fetch() !== false;
$stmt = $pdo->query("SHOW COLUMNS FROM tasks LIKE 'recurring_series_id'");
$recurringSeriesIdExists = $stmt->fetch() !== false;
$stmt = $pdo->query("SHOW COLUMNS FROM tasks LIKE 'recurrence_type'");
$recurrenceTypeExists = $stmt->fetch() !== false;
// Add missing columns
if (!$isRecurringExists) {
echo "Adding is_recurring column...\n";
$pdo->exec("ALTER TABLE tasks ADD COLUMN is_recurring TINYINT(1) DEFAULT 0");
echo "ā is_recurring column added\n";
} else {
echo "ā is_recurring column already exists\n";
}
if (!$recurringSeriesIdExists) {
echo "Adding recurring_series_id column...\n";
$pdo->exec("ALTER TABLE tasks ADD COLUMN recurring_series_id VARCHAR(50) NULL");
echo "ā recurring_series_id column added\n";
} else {
echo "ā recurring_series_id column already exists\n";
}
if (!$recurrenceTypeExists) {
echo "Adding recurrence_type column...\n";
$pdo->exec("ALTER TABLE tasks ADD COLUMN recurrence_type ENUM('daily', 'weekly', 'monthly') NULL");
echo "ā recurrence_type column added\n";
} else {
echo "ā recurrence_type column already exists\n";
}
// Also check if end_date column exists (in case it's missing too)
$stmt = $pdo->query("SHOW COLUMNS FROM tasks LIKE 'end_date'");
$endDateExists = $stmt->fetch() !== false;
if (!$endDateExists) {
echo "Adding end_date column...\n";
$pdo->exec("ALTER TABLE tasks ADD COLUMN end_date DATE NULL AFTER date");
echo "ā end_date column added\n";
} else {
echo "ā end_date column already exists\n";
}
echo "\nā
Database migration completed successfully!\n";
echo "You can now use the recurring task functionality.\n";
} catch (Exception $e) {
echo "ā Migration failed: " . $e->getMessage() . "\n";
echo "Please check your database connection and try again.\n";
}
?>