tableExists($em, 'Sessions')) { $this->dropTable($em, 'SessionModules'); $this->dropTable($em, 'Sessions'); } } /** * {@inheritdoc} */ public function isApplyable(Application $app) { return $this->tableExists($app['orm.em'], 'Sessions'); } /** * {@inheritdoc} */ public function rollback(EntityManager $em, \appbox $appbox, Configuration $conf) { } /** * Checks whether the table exists or not. * * @param EntityManager $em * @param string $table * * @return boolean */ private function tableExists(EntityManager $em, $table) { return (Boolean) $em->createNativeQuery( 'SHOW TABLE STATUS WHERE Name="'.$table.'" COLLATE utf8_bin ', (new ResultSetMapping())->addScalarResult('Name', 'Name') )->getOneOrNullResult(); } /** * @param EntityManager $em * @param $tableName */ private function dropTable(EntityManager $em, $tableName) { $em->getConnection()->getSchemaManager()->dropTable($tableName); } }