<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220504090443 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$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');
$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)', [
'normalTitle' => '1 Week',
'normalAmount' => 1.7,
'normalHours' => 24 * 7,
'expeditedTitle' => '72 Hours',
'expeditedAmount' => 2.5,
'expeditedHours' => 72,
'hurryTitle' => '24 Hours',
'hurryAmount' => 3.5,
'hurryHours' => 24,
'percent' => 30,
]);
$this->addSql('ALTER TABLE campaign CHANGE speed speed_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE campaign ADD CONSTRAINT FK_1F1512DD8F3A8393 FOREIGN KEY (speed_id) REFERENCES speed (id)');
$this->addSql('CREATE INDEX IDX_1F1512DD8F3A8393 ON campaign (speed_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE campaign DROP FOREIGN KEY FK_1F1512DD8F3A8393');
$this->addSql('DROP TABLE speed');
$this->addSql('DROP INDEX IDX_1F1512DD8F3A8393 ON campaign');
$this->addSql('ALTER TABLE campaign CHANGE speed_id speed SMALLINT UNSIGNED DEFAULT 1 NOT NULL');
}
public function isTransactional(): bool
{
return false;
}
}