migrations/2019/10/Version20191009081048.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. final class Version20191009081048 extends AbstractMigration
  7. {
  8.     public function up(Schema $schema): void
  9.     {
  10.         $this->addSql('ALTER TABLE profit_calculation_row ADD date_time DATETIME');
  11.         $this->addSql('UPDATE profit_calculation_row pcr SET pcr.date_time = CONCAT("1-", pcr.month, "-1 00:00:00")');
  12.         $this->addSql('ALTER TABLE profit_calculation_row DROP month');
  13.     }
  14.     public function down(Schema $schema): void
  15.     {
  16.         $this->addSql('ALTER TABLE profit_calculation_row ADD month INT UNSIGNED NOT NULL');
  17.         $this->addSql('UPDATE profit_calculation_row pcr SET pcr.month = MONTH(pcr.date_time)');
  18.         $this->addSql('ALTER TABLE profit_calculation_row DROP date_time');
  19.     }
  20. }