I have this code but does not work:
<?php
namespace ApplicationMigrations;
use DoctrineDBALMigrationsAbstractMigration,
DoctrineDBALSchemaSchema;
/**
* Auto-generated Migration: Please modify to your need!
*/
class Version20131021150555 extends AbstractMigration
{
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");
$this->addSql("ALTER TABLE person ADD tellphone LONGTEXT DEFAULT NULL");
$em = $em = $this->getDoctrine()->getEntityManager();
$persons = $em->getRepository('AutogestionBundle:Person')->fetchAll();
foreach($persons as $person){
$person->setTellPhone($person->getCellPhone());
$em->persist($person);
}
$em->flush();
}
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");
$this->addSql("ALTER TABLE person DROP tellphone");
}
}
I have add info in cellphone in a new field tellphone.
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…