migrations/Version20151007143213.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 Version20151007143213 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 ADD tyre_type LONGTEXT DEFAULT NULL, ADD created_at DATETIME DEFAULT NULL, ADD updated_at DATETIME DEFAULT NULL');
  15.         $this->addSql('ALTER TABLE truck_model ADD rear_tyres LONGTEXT DEFAULT NULL, ADD front_tyres LONGTEXT DEFAULT NULL, ADD created_at DATETIME DEFAULT NULL, ADD updated_at DATETIME DEFAULT NULL, ADD fuel LONGTEXT DEFAULT NULL');
  16.         $this->addSql('UPDATE truck_model SET front_tyres = (SELECT front_tyres FROM truck WHERE front_tyres IS NOT NULL AND model_id = truck_model.id LIMIT 1)');
  17.         $this->addSql('UPDATE truck_model SET rear_tyres = (SELECT rear_tyres FROM truck WHERE rear_tyres IS NOT NULL AND model_id = truck_model.id LIMIT 1)');
  18.         $this->addSql('UPDATE truck_model SET fuel = (SELECT fuel FROM truck WHERE fuel IS NOT NULL AND model_id = truck_model.id LIMIT 1)');
  19.         $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)');
  20.         $this->addSql('ALTER TABLE truck DROP fuel, DROP front_tyres, DROP rear_tyres');
  21.         $this->addSql('ALTER TABLE truck_model DROP tyre_type');
  22.     }
  23.     public function down(Schema $schema): void
  24.     {
  25.         // this down() migration is auto-generated, please modify it to your needs
  26.         $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql''Migration can only be executed safely on \'mysql\'.');
  27.         $this->addSql('ALTER TABLE truck_model ADD tyre_type LONGTEXT DEFAULT NULL');
  28.         $this->addSql('ALTER TABLE truck ADD rear_tyres LONGTEXT DEFAULT NULL, ADD front_tyres LONGTEXT DEFAULT NULL, ADD fuel LONGTEXT DEFAULT NULL');
  29.         $this->addSql('UPDATE truck SET front_tyres = (SELECT front_tyres FROM truck_model WHERE front_tyres IS NOT NULL AND id = truck.model_id LIMIT 1)');
  30.         $this->addSql('UPDATE truck SET rear_tyres = (SELECT rear_tyres FROM truck_model WHERE rear_tyres IS NOT NULL AND id = truck.model_id LIMIT 1)');
  31.         $this->addSql('UPDATE truck SET fuel = (SELECT fuel FROM truck_model WHERE fuel IS NOT NULL AND id = truck.model_id LIMIT 1)');
  32.         $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)');
  33.         $this->addSql('ALTER TABLE truck_model DROP fuel, DROP front_tyres, DROP rear_tyres, DROP created_at, DROP updated_at');
  34.         $this->addSql('ALTER TABLE truck DROP tyre_type, DROP created_at, DROP updated_at');
  35.     }
  36. }