<?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 Version20221020135809 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 api_admin (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, api_token VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_AC9B59A6E7927C74 (email), UNIQUE INDEX UNIQ_AC9B59A67BA2F5EB (api_token), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE candidat (id INT NOT NULL, type_candidat_id INT DEFAULT NULL, lien_id INT DEFAULT NULL, nom VARCHAR(255) NOT NULL, prenom VARCHAR(255) NOT NULL, adresse VARCHAR(255) DEFAULT NULL, code_postal VARCHAR(5) DEFAULT NULL, ville VARCHAR(255) DEFAULT NULL, date_de_naissance DATE DEFAULT NULL, ville_naissance VARCHAR(255) DEFAULT NULL, departement_naissance VARCHAR(2) DEFAULT NULL, pays_naissance VARCHAR(255) DEFAULT NULL, numero_ss VARCHAR(15) DEFAULT NULL, nom_usage VARCHAR(255) DEFAULT NULL, complement_adresse VARCHAR(255) DEFAULT NULL, date_expiration_ts DATE DEFAULT NULL, sexe VARCHAR(255) DEFAULT NULL, statut INT DEFAULT NULL, email VARCHAR(255) NOT NULL, date_previs_embauche DATE DEFAULT NULL, poste VARCHAR(255) NOT NULL, site VARCHAR(255) NOT NULL, delai_formulaire DATE NOT NULL, mdp VARCHAR(255) NOT NULL, a_diplome TINYINT(1) DEFAULT NULL, nationnalite VARCHAR(255) DEFAULT NULL, cle VARCHAR(10) DEFAULT NULL, INDEX IDX_6AB5B47143C93C13 (type_candidat_id), UNIQUE INDEX UNIQ_6AB5B471EDAAC352 (lien_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE document (id INT AUTO_INCREMENT NOT NULL, candidat_id INT DEFAULT NULL, url VARCHAR(255) NOT NULL, nom VARCHAR(255) NOT NULL, extension VARCHAR(255) NOT NULL, taille INT NOT NULL, INDEX IDX_D8698A768D0EB82 (candidat_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE document_type_document (document_id INT NOT NULL, type_document_id INT NOT NULL, INDEX IDX_32390901C33F7837 (document_id), INDEX IDX_323909018826AFA6 (type_document_id), PRIMARY KEY(document_id, type_document_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE lien (id INT NOT NULL, utilisateur_id INT NOT NULL, token VARCHAR(255) NOT NULL, date_limite DATE NOT NULL, INDEX IDX_A532B4B5FB88E14F (utilisateur_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE type_candidat (id INT NOT NULL, libelle VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE type_candidat_type_document (type_candidat_id INT NOT NULL, type_document_id INT NOT NULL, INDEX IDX_25FA6D4443C93C13 (type_candidat_id), INDEX IDX_25FA6D448826AFA6 (type_document_id), PRIMARY KEY(type_candidat_id, type_document_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE type_document (id INT NOT NULL, libelle VARCHAR(255) NOT NULL, obligatoire TINYINT(1) NOT NULL, multiple TINYINT(1) NOT NULL, format VARCHAR(10) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE utilisateur (id INT NOT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_1D1C63B3E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE candidat ADD CONSTRAINT FK_6AB5B47143C93C13 FOREIGN KEY (type_candidat_id) REFERENCES type_candidat (id)');
$this->addSql('ALTER TABLE candidat ADD CONSTRAINT FK_6AB5B471EDAAC352 FOREIGN KEY (lien_id) REFERENCES lien (id)');
$this->addSql('ALTER TABLE document ADD CONSTRAINT FK_D8698A768D0EB82 FOREIGN KEY (candidat_id) REFERENCES candidat (id)');
$this->addSql('ALTER TABLE document_type_document ADD CONSTRAINT FK_32390901C33F7837 FOREIGN KEY (document_id) REFERENCES document (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE document_type_document ADD CONSTRAINT FK_323909018826AFA6 FOREIGN KEY (type_document_id) REFERENCES type_document (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE lien ADD CONSTRAINT FK_A532B4B5FB88E14F FOREIGN KEY (utilisateur_id) REFERENCES utilisateur (id)');
$this->addSql('ALTER TABLE type_candidat_type_document ADD CONSTRAINT FK_25FA6D4443C93C13 FOREIGN KEY (type_candidat_id) REFERENCES type_candidat (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE type_candidat_type_document ADD CONSTRAINT FK_25FA6D448826AFA6 FOREIGN KEY (type_document_id) REFERENCES type_document (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE document DROP FOREIGN KEY FK_D8698A768D0EB82');
$this->addSql('ALTER TABLE document_type_document DROP FOREIGN KEY FK_32390901C33F7837');
$this->addSql('ALTER TABLE candidat DROP FOREIGN KEY FK_6AB5B471EDAAC352');
$this->addSql('ALTER TABLE candidat DROP FOREIGN KEY FK_6AB5B47143C93C13');
$this->addSql('ALTER TABLE type_candidat_type_document DROP FOREIGN KEY FK_25FA6D4443C93C13');
$this->addSql('ALTER TABLE document_type_document DROP FOREIGN KEY FK_323909018826AFA6');
$this->addSql('ALTER TABLE type_candidat_type_document DROP FOREIGN KEY FK_25FA6D448826AFA6');
$this->addSql('ALTER TABLE lien DROP FOREIGN KEY FK_A532B4B5FB88E14F');
$this->addSql('DROP TABLE api_admin');
$this->addSql('DROP TABLE candidat');
$this->addSql('DROP TABLE document');
$this->addSql('DROP TABLE document_type_document');
$this->addSql('DROP TABLE lien');
$this->addSql('DROP TABLE type_candidat');
$this->addSql('DROP TABLE type_candidat_type_document');
$this->addSql('DROP TABLE type_document');
$this->addSql('DROP TABLE utilisateur');
}
}