I am creating a custom table in wordpress, while switching the theme from A to B, in the admin panel.
add_action('after_switch_theme', 'manage_student_reports');
function manage_student_reports() {
$sql = "CREATE TABLE IF NOT EXISTS `wp_student_reports` (
`report_id` int(20) NOT NULL AUTO_INCREMENT,
`student_name` varchar(50) NOT NULL,
`department` varchar(50) DEFAULT NULL,
`percentage` tinyint(4) DEFAULT '0',
PRIMARY KEY (`report_id`)
);";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
But when i switch back the theme from B to A (or something else), the table still exists in the wordpress database. Is there a way to drop it ?