Skip to content

Instantly share code, notes, and snippets.

@weaverryan
Created June 15, 2016 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weaverryan/cda3b87f6ab8d2878dd044d269ec6c90 to your computer and use it in GitHub Desktop.
Save weaverryan/cda3b87f6ab8d2878dd044d269ec6c90 to your computer and use it in GitHub Desktop.
Migrations Fix
<?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