<?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 Version20231117165423 extends AbstractMigration
{
public function getDescription(): string
{
return 'Survey';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE answer (id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, question_id BIGINT UNSIGNED DEFAULT NULL, answer_text LONGTEXT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_DADD4A251E27F6BF (question_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE answer_sub_questions (answer_id BIGINT UNSIGNED NOT NULL, question_id BIGINT UNSIGNED NOT NULL, INDEX IDX_D6773740AA334807 (answer_id), INDEX IDX_D67737401E27F6BF (question_id), PRIMARY KEY(answer_id, question_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE question (id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, parent_question_id BIGINT UNSIGNED DEFAULT NULL, question_text LONGTEXT NOT NULL, question_type VARCHAR(255) NOT NULL, tech_name VARCHAR(255) DEFAULT NULL, position BIGINT UNSIGNED NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_B6F7494E48900AE7 (tech_name), INDEX IDX_B6F7494E750BE4CF (parent_question_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user_answer (id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL, creator_id BIGINT UNSIGNED DEFAULT NULL, question_id BIGINT UNSIGNED DEFAULT NULL, answer_id BIGINT UNSIGNED DEFAULT NULL, answer_text LONGTEXT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, INDEX IDX_BF8F511861220EA6 (creator_id), INDEX IDX_BF8F51181E27F6BF (question_id), INDEX IDX_BF8F5118AA334807 (answer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE answer ADD CONSTRAINT FK_DADD4A251E27F6BF FOREIGN KEY (question_id) REFERENCES question (id)');
$this->addSql('ALTER TABLE answer_sub_questions ADD CONSTRAINT FK_D6773740AA334807 FOREIGN KEY (answer_id) REFERENCES answer (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE answer_sub_questions ADD CONSTRAINT FK_D67737401E27F6BF FOREIGN KEY (question_id) REFERENCES question (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE question ADD CONSTRAINT FK_B6F7494E750BE4CF FOREIGN KEY (parent_question_id) REFERENCES question (id)');
$this->addSql('ALTER TABLE user_answer ADD CONSTRAINT FK_BF8F511861220EA6 FOREIGN KEY (creator_id) REFERENCES creator (id)');
$this->addSql('ALTER TABLE user_answer ADD CONSTRAINT FK_BF8F51181E27F6BF FOREIGN KEY (question_id) REFERENCES question (id)');
$this->addSql('ALTER TABLE user_answer ADD CONSTRAINT FK_BF8F5118AA334807 FOREIGN KEY (answer_id) REFERENCES answer (id)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE answer DROP FOREIGN KEY FK_DADD4A251E27F6BF');
$this->addSql('ALTER TABLE answer_sub_questions DROP FOREIGN KEY FK_D6773740AA334807');
$this->addSql('ALTER TABLE answer_sub_questions DROP FOREIGN KEY FK_D67737401E27F6BF');
$this->addSql('ALTER TABLE question DROP FOREIGN KEY FK_B6F7494E750BE4CF');
$this->addSql('ALTER TABLE user_answer DROP FOREIGN KEY FK_BF8F511861220EA6');
$this->addSql('ALTER TABLE user_answer DROP FOREIGN KEY FK_BF8F51181E27F6BF');
$this->addSql('ALTER TABLE user_answer DROP FOREIGN KEY FK_BF8F5118AA334807');
$this->addSql('DROP TABLE answer');
$this->addSql('DROP TABLE answer_sub_questions');
$this->addSql('DROP TABLE question');
$this->addSql('DROP TABLE user_answer');
}
}