-
-
Save weaverryan/cda3b87f6ab8d2878dd044d269ec6c90 to your computer and use it in GitHub Desktop.
Migrations Fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Application\Migrations; | |
use Doctrine\DBAL\Migrations\AbstractMigration, | |
Doctrine\DBAL\Schema\Schema; | |
/** | |
* Auto-generated Migration: Please modify to your need! | |
*/ | |
class Version20160207092254 extends AbstractMigration | |
{ | |
public function up(Schema $schema) | |
{ | |
// this up() migration is autogenerated, please modify it to your needs | |
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); | |
// drop the old FKey | |
$this->addSql("ALTER TABLE genus_note DROP FOREIGN KEY FK_6478FCEC85C4074C"); | |
$this->addSql("DROP INDEX IDX_6478FCEC85C4074C ON genus_note"); | |
// alert | |
$this->addSql("ALTER TABLE genus_note CHANGE genus_id genus_id INT NOT NULL"); | |
// re-add the FKEY | |
$this->addSql("ALTER TABLE genus_note ADD CONSTRAINT FK_6478FCEC85C4074C FOREIGN KEY (genus_id) REFERENCES genus (id)"); | |
$this->addSql("CREATE INDEX IDX_6478FCEC85C4074C ON genus_note (genus_id)"); | |
} | |
public function down(Schema $schema) | |
{ | |
// this down() migration is autogenerated, please modify it to your needs | |
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); | |
$this->addSql("ALTER TABLE genus_note CHANGE genus_id genus_id INT DEFAULT NULL"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment