migrations/Version20151006152852.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 Version20151006152852 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('ALTER TABLE truck_model DROP FOREIGN KEY FK_564EC303CE62929E');
  15.         $this->addSql('DROP INDEX IDX_564EC303CE62929E ON truck_model');
  16.         $this->addSql('ALTER TABLE truck_model ADD tyre_type LONGTEXT DEFAULT NULL, CHANGE waterfilter_id fuelFilter_id INT DEFAULT NULL');
  17.         $this->addSql('ALTER TABLE truck_model ADD CONSTRAINT FK_564EC30340BE4F32 FOREIGN KEY (fuelFilter_id) REFERENCES stock (id)');
  18.         $this->addSql('CREATE INDEX IDX_564EC30340BE4F32 ON truck_model (fuelFilter_id)');
  19.         $this->addSql('UPDATE truck_model SET tyre_type = (SELECT tyre_type FROM truck WHERE tyre_type IS NOT NULL AND model_id = truck_model.id LIMIT 1)');
  20.         $this->addSql('ALTER TABLE truck DROP tyre_type');
  21.     }
  22.     public function down(Schema $schema): void
  23.     {
  24.         // this down() migration is auto-generated, please modify it to your needs
  25.         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql''Migration can only be executed safely on \'mysql\'.');
  26.         $this->addSql('ALTER TABLE truck ADD tyre_type LONGTEXT DEFAULT NULL');
  27.         $this->addSql('UPDATE truck SET tyre_type = (SELECT tyre_type FROM truck_model WHERE tyre_type IS NOT NULL AND id = truck.model_id LIMIT 1)');
  28.         $this->addSql('ALTER TABLE truck_model DROP FOREIGN KEY FK_564EC30340BE4F32');
  29.         $this->addSql('DROP INDEX IDX_564EC30340BE4F32 ON truck_model');
  30.         $this->addSql('ALTER TABLE truck_model DROP tyre_type, CHANGE fuelfilter_id waterFilter_id INT DEFAULT NULL');
  31.         $this->addSql('ALTER TABLE truck_model ADD CONSTRAINT FK_564EC303CE62929E FOREIGN KEY (waterFilter_id) REFERENCES stock (id)');
  32.         $this->addSql('CREATE INDEX IDX_564EC303CE62929E ON truck_model (waterFilter_id)');
  33.     }
  34. }