<?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 Version20241031072025 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 survey (id INT AUTO_INCREMENT NOT NULL, service_id INT DEFAULT NULL, service_year INT NOT NULL, title VARCHAR(255) NOT NULL, hash VARCHAR(255) NOT NULL, status INT NOT NULL, is_removed TINYINT(1) NOT NULL, cdate DATETIME NOT NULL, mdate DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_AD5F9BFCD1B862B8 (hash), INDEX IDX_AD5F9BFCED5CA9E6 (service_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE survey ADD CONSTRAINT FK_AD5F9BFCED5CA9E6 FOREIGN KEY (service_id) REFERENCES service (id)');
$this->addSql('ALTER TABLE form_section DROP FOREIGN KEY FK_1C1F1AD45FF69B7D');
$this->addSql('DROP INDEX IDX_1C1F1AD45FF69B7D ON form_section');
$this->addSql('ALTER TABLE form_section CHANGE form_id survey_id INT NOT NULL');
$this->addSql('ALTER TABLE form_section ADD CONSTRAINT FK_1C1F1AD4B3FE509D FOREIGN KEY (survey_id) REFERENCES survey (id)');
$this->addSql('CREATE INDEX IDX_1C1F1AD4B3FE509D ON form_section (survey_id)');
$this->addSql('ALTER TABLE taxation ADD survey_id INT NOT NULL, ADD is_survey TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE taxation ADD CONSTRAINT FK_C8EE2A50B3FE509D FOREIGN KEY (survey_id) REFERENCES survey (id)');
$this->addSql('CREATE INDEX IDX_C8EE2A50B3FE509D ON taxation (survey_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE form_section DROP FOREIGN KEY FK_1C1F1AD4B3FE509D');
$this->addSql('ALTER TABLE taxation DROP FOREIGN KEY FK_C8EE2A50B3FE509D');
$this->addSql('ALTER TABLE survey DROP FOREIGN KEY FK_AD5F9BFCED5CA9E6');
$this->addSql('DROP TABLE survey');
$this->addSql('DROP INDEX IDX_1C1F1AD4B3FE509D ON form_section');
$this->addSql('ALTER TABLE form_section CHANGE survey_id form_id INT NOT NULL');
$this->addSql('ALTER TABLE form_section ADD CONSTRAINT FK_1C1F1AD45FF69B7D FOREIGN KEY (form_id) REFERENCES form (id)');
$this->addSql('CREATE INDEX IDX_1C1F1AD45FF69B7D ON form_section (form_id)');
$this->addSql('DROP INDEX IDX_C8EE2A50B3FE509D ON taxation');
$this->addSql('ALTER TABLE taxation DROP survey_id, DROP is_survey');
}
}