exec($sql_volunteers); echo "Database table 'volunteers' created successfully (if it didn't exist).\n"; // volunteer_assignments table $sql_assignments = " CREATE TABLE IF NOT EXISTS volunteer_assignments ( id INT AUTO_INCREMENT PRIMARY KEY, listing_id INT NOT NULL, volunteer_id INT NOT NULL, assigned_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (listing_id) REFERENCES food_listings(id) ON DELETE CASCADE, FOREIGN KEY (volunteer_id) REFERENCES volunteers(id) ON DELETE CASCADE );"; $pdo->exec($sql_assignments); echo "Database table 'volunteer_assignments' created successfully (if it didn't exist).\n"; // Add 'assigned' to the status enum in food_listings // Note: This might fail if the enum value already exists, which is fine. try { $sql_alter_listings = "ALTER TABLE food_listings MODIFY status ENUM('available', 'claimed', 'collected', 'assigned') DEFAULT 'available'"; $pdo->exec($sql_alter_listings); echo "Altered 'food_listings' table to add 'assigned' status.\n"; } catch (PDOException $e) { // This will likely throw an error if you run it more than once. echo "Could not alter 'food_listings' table (maybe 'assigned' status already exists).\n"; } } catch (PDOException $e) { die("DB ERROR: " . $e->getMessage()); }