public function delete() { //delete tables $connection = Yii::app()->db; //get connection $dbSchema = $connection->schema; //or $connection->getSchema(); $tables = $dbSchema->getTableNames(); //returns array of tbl schema's foreach ($tables as $tbl) { if (strpos($tbl, $this->prefix) === 0) { //echo $tbl->rawName, ":<br/>", implode(', ', $tbl->columnNames), "<br/>\n"; //$dbSchema->dropTable($tbl); $command = $connection->createCommand($dbSchema->dropTable($tbl)); $command->execute(); // execute the non-query SQL //echo "holyshit:". $tbl . "<br/>\n"; } } //delete folders $folder = $this->getFilePath($this); CFileHelper::removeDirectory($folder); //delete db perms return parent::delete(); }