<?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 Version20210826152207 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 bonus (id INT AUTO_INCREMENT NOT NULL, resource_id INT DEFAULT NULL, project_id INT DEFAULT NULL, status VARCHAR(50) NOT NULL, number INT NOT NULL, price NUMERIC(10, 2) NOT NULL, INDEX IDX_9F987F7A89329D25 (resource_id), INDEX IDX_9F987F7A166D1F9C (project_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE currency (id VARCHAR(255) NOT NULL, display VARCHAR(50) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('INSERT INTO currency (id, display) VALUES ("EUR", "Euro")');
$this->addSql('INSERT INTO currency (id, display) VALUES ("CAD", "Canadian dollar")');
$this->addSql('INSERT INTO currency (id, display) VALUES ("ZAR", "South african rand")');
$this->addSql('ALTER TABLE bonus ADD CONSTRAINT FK_9F987F7A89329D25 FOREIGN KEY (resource_id) REFERENCES resource (id)');
$this->addSql('ALTER TABLE bonus ADD CONSTRAINT FK_9F987F7A166D1F9C FOREIGN KEY (project_id) REFERENCES project (id)');
$this->addSql('ALTER TABLE project ADD currency_id VARCHAR(255) DEFAULT NULL, ADD bonuses LONGTEXT DEFAULT NULL, ADD bonus_osts LONGTEXT DEFAULT NULL, ADD sponsor_cost NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE project ADD CONSTRAINT FK_2FB3D0EE38248176 FOREIGN KEY (currency_id) REFERENCES currency (id)');
$this->addSql('CREATE INDEX IDX_2FB3D0EE38248176 ON project (currency_id)');
$this->addSql('ALTER TABLE resource DROP bonus, CHANGE currency currency VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE resource ADD CONSTRAINT FK_BC91F4166956883F FOREIGN KEY (currency) REFERENCES currency (id)');
$this->addSql('CREATE INDEX IDX_BC91F4166956883F ON resource (currency)');
$this->addSql('ALTER TABLE project ADD script_cost NUMERIC(10, 2) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE project DROP FOREIGN KEY FK_2FB3D0EE38248176');
$this->addSql('ALTER TABLE resource DROP FOREIGN KEY FK_BC91F4166956883F');
$this->addSql('DROP TABLE bonus');
$this->addSql('DROP TABLE currency');
$this->addSql('DROP INDEX IDX_2FB3D0EE38248176 ON project');
$this->addSql('ALTER TABLE project DROP currency_id, DROP bonuses, DROP bonus_osts, DROP sponsor_cost');
$this->addSql('DROP INDEX IDX_BC91F4166956883F ON resource');
$this->addSql('ALTER TABLE resource ADD bonus VARCHAR(25) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE currency currency VARCHAR(3) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`');
$this->addSql('ALTER TABLE project DROP script_cost');
}
}