migrations/Version20230629133245.php line 1
<?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 Version20230629133245 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 customer (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE given_answer (id INT AUTO_INCREMENT NOT NULL, customer_id INT NOT NULL, question_id INT NOT NULL, answer LONGTEXT NOT NULL, INDEX IDX_9AC61A309395C3F3 (customer_id), INDEX IDX_9AC61A301E27F6BF (question_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE poll_questions (id INT AUTO_INCREMENT NOT NULL, poll_id INT DEFAULT NULL, question VARCHAR(255) NOT NULL, type VARCHAR(20) NOT NULL, INDEX IDX_410B7D213C947C0F (poll_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE polls (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE question_options (id INT AUTO_INCREMENT NOT NULL, question_id INT NOT NULL, option_text VARCHAR(255) NOT NULL, INDEX IDX_DEE92F9A1E27F6BF (question_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE given_answer ADD CONSTRAINT FK_9AC61A309395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id)');
$this->addSql('ALTER TABLE given_answer ADD CONSTRAINT FK_9AC61A301E27F6BF FOREIGN KEY (question_id) REFERENCES poll_questions (id)');
$this->addSql('ALTER TABLE poll_questions ADD CONSTRAINT FK_410B7D213C947C0F FOREIGN KEY (poll_id) REFERENCES polls (id)');
$this->addSql('ALTER TABLE question_options ADD CONSTRAINT FK_DEE92F9A1E27F6BF FOREIGN KEY (question_id) REFERENCES poll_questions (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE given_answer DROP FOREIGN KEY FK_9AC61A309395C3F3');
$this->addSql('ALTER TABLE given_answer DROP FOREIGN KEY FK_9AC61A301E27F6BF');
$this->addSql('ALTER TABLE poll_questions DROP FOREIGN KEY FK_410B7D213C947C0F');
$this->addSql('ALTER TABLE question_options DROP FOREIGN KEY FK_DEE92F9A1E27F6BF');
$this->addSql('DROP TABLE customer');
$this->addSql('DROP TABLE given_answer');
$this->addSql('DROP TABLE poll_questions');
$this->addSql('DROP TABLE polls');
$this->addSql('DROP TABLE question_options');
}
}