<?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 Version20220217205712 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 address (id INT AUTO_INCREMENT NOT NULL, citizen_id INT DEFAULT NULL, city VARCHAR(255) DEFAULT NULL, zip_code VARCHAR(100) DEFAULT NULL, department VARCHAR(255) DEFAULT NULL, region VARCHAR(255) DEFAULT NULL, is_principal TINYINT(1) DEFAULT 1, INDEX IDX_D4E6F81A63C3C2E (citizen_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE citizen (id INT NOT NULL, birthplace_address_id INT DEFAULT NULL, sensibility_id INT DEFAULT NULL, profession VARCHAR(255) NOT NULL, show_political TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_A95317297DD23F07 (birthplace_address_id), INDEX IDX_A95317298281FDC0 (sensibility_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE mandate (id INT AUTO_INCREMENT NOT NULL, address_id INT DEFAULT NULL, politician_id INT DEFAULT NULL, type VARCHAR(255) NOT NULL, is_active TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_197D0FEEF5B7AF75 (address_id), INDEX IDX_197D0FEE899F0176 (politician_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE political_party (id INT AUTO_INCREMENT NOT NULL, logo VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL, abbreviation VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, is_active TINYINT(1) DEFAULT 1 NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE politician (id INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE sensibility (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, type VARCHAR(255) DEFAULT NULL, is_active TINYINT(1) DEFAULT 1 NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, political_party_id INT DEFAULT NULL, email VARCHAR(180) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, firstname VARCHAR(255) NOT NULL, lastname VARCHAR(255) NOT NULL, birth_date DATETIME NOT NULL, genre VARCHAR(255) NOT NULL, phone VARCHAR(255) DEFAULT NULL, avatar VARCHAR(255) DEFAULT NULL, cover VARCHAR(255) DEFAULT NULL, dtype VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), INDEX IDX_8D93D64927268D9C (political_party_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, available_at DATETIME NOT NULL, delivered_at DATETIME DEFAULT NULL, INDEX IDX_75EA56E016BA31DB (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE address ADD CONSTRAINT FK_D4E6F81A63C3C2E FOREIGN KEY (citizen_id) REFERENCES citizen (id)');
$this->addSql('ALTER TABLE citizen ADD CONSTRAINT FK_A95317297DD23F07 FOREIGN KEY (birthplace_address_id) REFERENCES address (id)');
$this->addSql('ALTER TABLE citizen ADD CONSTRAINT FK_A95317298281FDC0 FOREIGN KEY (sensibility_id) REFERENCES sensibility (id)');
$this->addSql('ALTER TABLE citizen ADD CONSTRAINT FK_A9531729BF396750 FOREIGN KEY (id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE mandate ADD CONSTRAINT FK_197D0FEEF5B7AF75 FOREIGN KEY (address_id) REFERENCES address (id)');
$this->addSql('ALTER TABLE mandate ADD CONSTRAINT FK_197D0FEE899F0176 FOREIGN KEY (politician_id) REFERENCES politician (id)');
$this->addSql('ALTER TABLE politician ADD CONSTRAINT FK_B39BFB49BF396750 FOREIGN KEY (id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D64927268D9C FOREIGN KEY (political_party_id) REFERENCES political_party (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE citizen DROP FOREIGN KEY FK_A95317297DD23F07');
$this->addSql('ALTER TABLE mandate DROP FOREIGN KEY FK_197D0FEEF5B7AF75');
$this->addSql('ALTER TABLE address DROP FOREIGN KEY FK_D4E6F81A63C3C2E');
$this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D64927268D9C');
$this->addSql('ALTER TABLE mandate DROP FOREIGN KEY FK_197D0FEE899F0176');
$this->addSql('ALTER TABLE citizen DROP FOREIGN KEY FK_A95317298281FDC0');
$this->addSql('ALTER TABLE citizen DROP FOREIGN KEY FK_A9531729BF396750');
$this->addSql('ALTER TABLE politician DROP FOREIGN KEY FK_B39BFB49BF396750');
$this->addSql('DROP TABLE address');
$this->addSql('DROP TABLE citizen');
$this->addSql('DROP TABLE mandate');
$this->addSql('DROP TABLE political_party');
$this->addSql('DROP TABLE politician');
$this->addSql('DROP TABLE sensibility');
$this->addSql('DROP TABLE user');
$this->addSql('DROP TABLE messenger_messages');
}
}