Skip to content

Commit 884337a

Browse files
committed
Drop views and tables
1 parent d5ace4f commit 884337a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Bootstrap.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,29 @@ private static function dropTables(EntityManagerInterface $entityManager): void
8787
{
8888
$connection = $entityManager->getConnection();
8989

90-
$statement = $connection->prepare('SHOW TABLES');
90+
$statement = $connection->prepare('SHOW FULL TABLES WHERE Table_type = "BASE TABLE"');
9191
$statement->execute();
9292
$tables = $statement->fetchAll();
9393

9494
$connection->exec('SET foreign_key_checks = 0');
95-
echo "Dropping database\n";
95+
echo "Dropping tables\n";
9696
foreach ($tables as $table)
9797
{
9898
$tableName = current($table);
9999
$connection->exec('DROP TABLE `' . $tableName . '`');
100100
}
101101

102+
$statement = $connection->prepare('SHOW FULL TABLES WHERE Table_type = "VIEW"');
103+
$statement->execute();
104+
$views = $statement->fetchAll();
105+
106+
echo "Dropping views\n";
107+
foreach ($views as $view)
108+
{
109+
$viewName = current($view);
110+
$connection->exec('DROP VIEW `' . $viewName . '`');
111+
}
112+
102113
$connection->exec('SET foreign_key_checks = 1');
103114
}
104115

0 commit comments

Comments
 (0)