migrations/Version20220504090443.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20220504090443 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE TABLE speed (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, amount DOUBLE PRECISION NOT NULL, hours SMALLINT NOT NULL, percent SMALLINT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('INSERT INTO speed (id, title, amount, hours, percent) VALUES (1, :normalTitle, :normalAmount, :normalHours, :percent), (2, :expeditedTitle, :expeditedAmount, :expeditedHours, :percent), (3, :hurryTitle, :hurryAmount, :hurryHours, :percent)', [
  20.             'normalTitle' => '1 Week',
  21.             'normalAmount' => 1.7,
  22.             'normalHours' => 24 7,
  23.             'expeditedTitle' => '72 Hours',
  24.             'expeditedAmount' => 2.5,
  25.             'expeditedHours' => 72,
  26.             'hurryTitle' => '24 Hours',
  27.             'hurryAmount' => 3.5,
  28.             'hurryHours' => 24,
  29.             'percent' => 30,
  30.         ]);
  31.         $this->addSql('ALTER TABLE campaign CHANGE speed speed_id INT DEFAULT NULL');
  32.         $this->addSql('ALTER TABLE campaign ADD CONSTRAINT FK_1F1512DD8F3A8393 FOREIGN KEY (speed_id) REFERENCES speed (id)');
  33.         $this->addSql('CREATE INDEX IDX_1F1512DD8F3A8393 ON campaign (speed_id)');
  34.     }
  35.     public function down(Schema $schema): void
  36.     {
  37.         // this down() migration is auto-generated, please modify it to your needs
  38.         $this->addSql('ALTER TABLE campaign DROP FOREIGN KEY FK_1F1512DD8F3A8393');
  39.         $this->addSql('DROP TABLE speed');
  40.         $this->addSql('DROP INDEX IDX_1F1512DD8F3A8393 ON campaign');
  41.         $this->addSql('ALTER TABLE campaign CHANGE speed_id speed SMALLINT UNSIGNED DEFAULT 1 NOT NULL');
  42.     }
  43.     public function isTransactional(): bool
  44.     {
  45.         return false;
  46.     }
  47. }