migrations/Version20140709151702.php line 1

Open in your IDE?
  1. <?php
  2. namespace DoctrineMigrations;
  3. use Doctrine\DBAL\Schema\Schema;
  4. use Doctrine\Migrations\AbstractMigration;
  5. /**
  6.  * Auto-generated Migration: Please modify to your needs!
  7.  */
  8. class Version20140709151702 extends AbstractMigration
  9. {
  10.     public function up(Schema $schema): void
  11.     {
  12.         // this up() migration is auto-generated, please modify it to your needs
  13.         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql'"Migration can only be executed safely on 'mysql'.");
  14.         $this->addSql('CREATE TABLE stock_type (id INT AUTO_INCREMENT NOT NULL, type VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
  15.         $this->addSql('ALTER TABLE purchase_order ADD reference VARCHAR(100) DEFAULT NULL');
  16.         $this->addSql('ALTER TABLE stock ADD type_id INT DEFAULT NULL, DROP type');
  17.         $this->addSql('ALTER TABLE stock ADD CONSTRAINT FK_4B365660C54C8C93 FOREIGN KEY (type_id) REFERENCES stock_type (id) ON DELETE SET NULL');
  18.         $this->addSql('CREATE INDEX IDX_4B365660C54C8C93 ON stock (type_id)');
  19.     }
  20.     public function down(Schema $schema): void
  21.     {
  22.         // this down() migration is auto-generated, please modify it to your needs
  23.         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql'"Migration can only be executed safely on 'mysql'.");
  24.         $this->addSql('ALTER TABLE stock DROP FOREIGN KEY FK_4B365660C54C8C93');
  25.         $this->addSql('DROP TABLE stock_type');
  26.         $this->addSql('ALTER TABLE purchase_order DROP reference');
  27.         $this->addSql('DROP INDEX IDX_4B365660C54C8C93 ON stock');
  28.         $this->addSql('ALTER TABLE stock ADD type VARCHAR(100) DEFAULT NULL, DROP type_id');
  29.     }
  30. }