migrations/Version20230629133245.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20230629133245 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $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');
  19.         $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');
  20.         $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');
  21.         $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');
  22.         $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');
  23.         $this->addSql('ALTER TABLE given_answer ADD CONSTRAINT FK_9AC61A309395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id)');
  24.         $this->addSql('ALTER TABLE given_answer ADD CONSTRAINT FK_9AC61A301E27F6BF FOREIGN KEY (question_id) REFERENCES poll_questions (id)');
  25.         $this->addSql('ALTER TABLE poll_questions ADD CONSTRAINT FK_410B7D213C947C0F FOREIGN KEY (poll_id) REFERENCES polls (id)');
  26.         $this->addSql('ALTER TABLE question_options ADD CONSTRAINT FK_DEE92F9A1E27F6BF FOREIGN KEY (question_id) REFERENCES poll_questions (id)');
  27.     }
  28.     public function down(Schema $schema): void
  29.     {
  30.         // this down() migration is auto-generated, please modify it to your needs
  31.         $this->addSql('ALTER TABLE given_answer DROP FOREIGN KEY FK_9AC61A309395C3F3');
  32.         $this->addSql('ALTER TABLE given_answer DROP FOREIGN KEY FK_9AC61A301E27F6BF');
  33.         $this->addSql('ALTER TABLE poll_questions DROP FOREIGN KEY FK_410B7D213C947C0F');
  34.         $this->addSql('ALTER TABLE question_options DROP FOREIGN KEY FK_DEE92F9A1E27F6BF');
  35.         $this->addSql('DROP TABLE customer');
  36.         $this->addSql('DROP TABLE given_answer');
  37.         $this->addSql('DROP TABLE poll_questions');
  38.         $this->addSql('DROP TABLE polls');
  39.         $this->addSql('DROP TABLE question_options');
  40.     }
  41. }