public function postDown(Schema $schema) { //$em = $this->container->get('doctrine.orm.entity_manager'); $query = "SELECT * FROM users"; $stmt = $this->connection->prepare($query); $stmt->execute(); $queryInsert = "INSERT INTO UserMetadata (roles, userid) VALUES(:roles, :userid)"; $stmtInsert = $this->connection->prepare($queryInsert); // We can't use Doctrine's ORM to fetch the item, because it has a load of extra fields // that aren't in the entity definition. while ($row = $stmt->fetch()) { //$user = $em->getRepository('BaikalSystemBundle:User')->find($row['userid']); $stmtInsert->bindValue('roles', $row['roles']); $stmtInsert->bindValue('userid', $row['id']); $stmtInsert->execute(); } $queryDrop = "ALTER TABLE users DROP roles"; $stmtDrop = $this->connection->prepare($queryDrop); $stmtDrop->execute(); }