5 * Populate the database schema.
8 if (!defined('CIVI_SETUP')) {
9 exit("Installation plugins must only be loaded by the installer.\n");
12 \Civi\Setup
::dispatcher()
13 ->addListener('civi.setup.uninstallDatabase', function (\Civi\Setup\Event\UninstallDatabaseEvent
$e) {
14 \Civi\Setup
::log()->info('[UninstallSchema.civi-setup.php] Remove all tables and views (civicrm_* and log_civicrm_*)');
15 $model = $e->getModel();
17 $conn = \Civi\Setup\DbUtil
::connect($model->db
);
18 \Civi\Setup\DbUtil
::execute($conn, 'SET FOREIGN_KEY_CHECKS=0;');
20 foreach (\Civi\Setup\DbUtil
::findViews($conn, $model->db
['database']) as $view) {
21 if (preg_match('/^(civicrm_|log_civicrm_)/', $view)) {
22 \Civi\Setup\DbUtil
::execute($conn, sprintf('DROP VIEW `%s`', $conn->escape_string($view)));
26 foreach (\Civi\Setup\DbUtil
::findTables($conn, $model->db
['database']) as $table) {
27 if (preg_match('/^(civicrm_|log_civicrm_)/', $table)) {
28 \Civi\Setup\DbUtil
::execute($conn, sprintf('DROP TABLE `%s`', $conn->escape_string($table)));
32 // TODO Perhaps we should also remove stored-procedures/functions?