prepare( 'SELECT 1 FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = :table LIMIT 1' ); $tableStmt->execute(['table' => 'invoices']); if ((bool)$tableStmt->fetchColumn()) { $columnStmt = $pdo->prepare( 'SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = :table AND COLUMN_NAME = :column LIMIT 1' ); $columnStmt->execute([ 'table' => 'invoices', 'column' => 'due_date', ]); if (!(bool)$columnStmt->fetchColumn()) { $pdo->exec('ALTER TABLE `invoices` ADD COLUMN `due_date` DATE DEFAULT NULL AFTER `invoice_date`'); } } return true;