migrations/Version20220913200603.php line 1

Open in your IDE?
  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 Version20220913200603 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 history_presidential_canditate (id INT AUTO_INCREMENT NOT NULL, firstname VARCHAR(255) NOT NULL, lastname VARCHAR(255) NOT NULL, avatar VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  19.         $this->addSql('CREATE TABLE history_presidential_first_round (id INT AUTO_INCREMENT NOT NULL, year VARCHAR(4) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  20.         $this->addSql('CREATE TABLE history_presidential_first_round_history_presidential_canditate (history_presidential_first_round_id INT NOT NULL, history_presidential_canditate_id INT NOT NULL, INDEX IDX_CCF0E3262D65FB7B (history_presidential_first_round_id), INDEX IDX_CCF0E326B26F3D7D (history_presidential_canditate_id), PRIMARY KEY(history_presidential_first_round_id, history_presidential_canditate_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  21.         $this->addSql('CREATE TABLE history_presidential_second_round (id INT AUTO_INCREMENT NOT NULL, year VARCHAR(4) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  22.         $this->addSql('CREATE TABLE history_presidential_second_round_history_presidential_canditate (history_presidential_second_round_id INT NOT NULL, history_presidential_canditate_id INT NOT NULL, INDEX IDX_4E92AE107893FD70 (history_presidential_second_round_id), INDEX IDX_4E92AE10B26F3D7D (history_presidential_canditate_id), PRIMARY KEY(history_presidential_second_round_id, history_presidential_canditate_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  23.         $this->addSql('CREATE TABLE history_vote (id INT AUTO_INCREMENT NOT NULL, citizen_id INT NOT NULL, year VARCHAR(4) NOT NULL, second_round VARCHAR(255) NOT NULL, first_round VARCHAR(255) NOT NULL, INDEX IDX_5125F518A63C3C2E (citizen_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  24.         $this->addSql('ALTER TABLE history_presidential_first_round_history_presidential_canditate ADD CONSTRAINT FK_CCF0E3262D65FB7B FOREIGN KEY (history_presidential_first_round_id) REFERENCES history_presidential_first_round (id) ON DELETE CASCADE');
  25.         $this->addSql('ALTER TABLE history_presidential_first_round_history_presidential_canditate ADD CONSTRAINT FK_CCF0E326B26F3D7D FOREIGN KEY (history_presidential_canditate_id) REFERENCES history_presidential_canditate (id) ON DELETE CASCADE');
  26.         $this->addSql('ALTER TABLE history_presidential_second_round_history_presidential_canditate ADD CONSTRAINT FK_4E92AE107893FD70 FOREIGN KEY (history_presidential_second_round_id) REFERENCES history_presidential_second_round (id) ON DELETE CASCADE');
  27.         $this->addSql('ALTER TABLE history_presidential_second_round_history_presidential_canditate ADD CONSTRAINT FK_4E92AE10B26F3D7D FOREIGN KEY (history_presidential_canditate_id) REFERENCES history_presidential_canditate (id) ON DELETE CASCADE');
  28.         $this->addSql('ALTER TABLE history_vote ADD CONSTRAINT FK_5125F518A63C3C2E FOREIGN KEY (citizen_id) REFERENCES citizen (id)');
  29.     }
  30.     public function down(Schema $schema): void
  31.     {
  32.         // this down() migration is auto-generated, please modify it to your needs
  33.         $this->addSql('ALTER TABLE history_presidential_first_round_history_presidential_canditate DROP FOREIGN KEY FK_CCF0E326B26F3D7D');
  34.         $this->addSql('ALTER TABLE history_presidential_second_round_history_presidential_canditate DROP FOREIGN KEY FK_4E92AE10B26F3D7D');
  35.         $this->addSql('ALTER TABLE history_presidential_first_round_history_presidential_canditate DROP FOREIGN KEY FK_CCF0E3262D65FB7B');
  36.         $this->addSql('ALTER TABLE history_presidential_second_round_history_presidential_canditate DROP FOREIGN KEY FK_4E92AE107893FD70');
  37.         $this->addSql('DROP TABLE history_presidential_canditate');
  38.         $this->addSql('DROP TABLE history_presidential_first_round');
  39.         $this->addSql('DROP TABLE history_presidential_first_round_history_presidential_canditate');
  40.         $this->addSql('DROP TABLE history_presidential_second_round');
  41.         $this->addSql('DROP TABLE history_presidential_second_round_history_presidential_canditate');
  42.         $this->addSql('DROP TABLE history_vote');
  43.     }
  44. }