<?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 Version20260427213300 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 etudiants (id INT AUTO_INCREMENT NOT NULL, matricule VARCHAR(40) DEFAULT NULL, matricule_temporaire VARCHAR(40) DEFAULT NULL, nom VARCHAR(120) NOT NULL, prenom VARCHAR(120) DEFAULT NULL, sexe VARCHAR(20) DEFAULT NULL, date_naissance DATE DEFAULT NULL, lieu_naissance VARCHAR(160) DEFAULT NULL, situation_matrimoniale VARCHAR(60) DEFAULT NULL, telephone_principal VARCHAR(30) DEFAULT NULL, telephone_whatsapp VARCHAR(30) DEFAULT NULL, autre_contact VARCHAR(120) DEFAULT NULL, email VARCHAR(180) DEFAULT NULL, adresse LONGTEXT DEFAULT NULL, ancien TINYINT DEFAULT 0 NOT NULL, actif TINYINT DEFAULT 1 NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, ecole_id INT NOT NULL, section_id INT DEFAULT NULL, niveau_id INT DEFAULT NULL, classe_id INT DEFAULT NULL, INDEX IDX_227C02EB77EF1B1E (ecole_id), INDEX IDX_227C02EBD823E37A (section_id), INDEX IDX_227C02EBB3E9C81 (niveau_id), INDEX IDX_227C02EB8F5EA509 (classe_id), UNIQUE INDEX UNIQ_ETUDIANT_MATRICULE (matricule), UNIQUE INDEX UNIQ_ETUDIANT_MATRICULE_TEMPORAIRE (matricule_temporaire), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
        $this->addSql('CREATE TABLE inscriptions (id INT AUTO_INCREMENT NOT NULL, numero_dossier VARCHAR(50) NOT NULL, matricule_temporaire VARCHAR(40) DEFAULT NULL, type_candidat VARCHAR(20) NOT NULL, ancien_matricule VARCHAR(40) DEFAULT NULL, nom VARCHAR(120) NOT NULL, prenom VARCHAR(120) DEFAULT NULL, sexe VARCHAR(20) DEFAULT NULL, date_naissance DATE DEFAULT NULL, lieu_naissance VARCHAR(160) DEFAULT NULL, situation_matrimoniale VARCHAR(60) DEFAULT NULL, telephone_principal VARCHAR(30) DEFAULT NULL, telephone_whatsapp VARCHAR(30) DEFAULT NULL, autre_contact VARCHAR(120) DEFAULT NULL, email VARCHAR(180) DEFAULT NULL, adresse LONGTEXT DEFAULT NULL, langue_souhaitee VARCHAR(40) DEFAULT NULL, mode_souhaite VARCHAR(40) DEFAULT NULL, observation_candidat LONGTEXT DEFAULT NULL, observation_admin LONGTEXT DEFAULT NULL, statut VARCHAR(30) NOT NULL, motif_rejet LONGTEXT DEFAULT NULL, fiche_pdf_path VARCHAR(255) DEFAULT NULL, whatsapp_notification_sent_at DATETIME DEFAULT NULL, whatsapp_last_error LONGTEXT DEFAULT NULL, date_soumission DATETIME NOT NULL, date_validation DATETIME DEFAULT NULL, date_rejet DATETIME DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, ecole_id INT NOT NULL, etudiant_id INT DEFAULT NULL, section_souhaitee_id INT DEFAULT NULL, niveau_souhaite_id INT DEFAULT NULL, classe_souhaitee_id INT DEFAULT NULL, section_finale_id INT DEFAULT NULL, niveau_final_id INT DEFAULT NULL, classe_finale_id INT DEFAULT NULL, INDEX IDX_74E0281C77EF1B1E (ecole_id), INDEX IDX_74E0281CDDEAB1A3 (etudiant_id), INDEX IDX_74E0281C8AAC02CD (section_souhaitee_id), INDEX IDX_74E0281CEB809123 (niveau_souhaite_id), INDEX IDX_74E0281CEB7D15A3 (classe_souhaitee_id), INDEX IDX_74E0281CB5824D8D (section_finale_id), INDEX IDX_74E0281CAAD2DB9E (niveau_final_id), INDEX IDX_74E0281CE69B7D2F (classe_finale_id), UNIQUE INDEX UNIQ_INSCRIPTION_NUMERO_DOSSIER (numero_dossier), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
        $this->addSql('ALTER TABLE etudiants ADD CONSTRAINT FK_227C02EB77EF1B1E FOREIGN KEY (ecole_id) REFERENCES ecoles (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE etudiants ADD CONSTRAINT FK_227C02EBD823E37A FOREIGN KEY (section_id) REFERENCES sections (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE etudiants ADD CONSTRAINT FK_227C02EBB3E9C81 FOREIGN KEY (niveau_id) REFERENCES niveaux (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE etudiants ADD CONSTRAINT FK_227C02EB8F5EA509 FOREIGN KEY (classe_id) REFERENCES classes (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE inscriptions ADD CONSTRAINT FK_74E0281C77EF1B1E FOREIGN KEY (ecole_id) REFERENCES ecoles (id) ON DELETE CASCADE');
        $this->addSql('ALTER TABLE inscriptions ADD CONSTRAINT FK_74E0281CDDEAB1A3 FOREIGN KEY (etudiant_id) REFERENCES etudiants (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE inscriptions ADD CONSTRAINT FK_74E0281C8AAC02CD FOREIGN KEY (section_souhaitee_id) REFERENCES sections (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE inscriptions ADD CONSTRAINT FK_74E0281CEB809123 FOREIGN KEY (niveau_souhaite_id) REFERENCES niveaux (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE inscriptions ADD CONSTRAINT FK_74E0281CEB7D15A3 FOREIGN KEY (classe_souhaitee_id) REFERENCES classes (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE inscriptions ADD CONSTRAINT FK_74E0281CB5824D8D FOREIGN KEY (section_finale_id) REFERENCES sections (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE inscriptions ADD CONSTRAINT FK_74E0281CAAD2DB9E FOREIGN KEY (niveau_final_id) REFERENCES niveaux (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE inscriptions ADD CONSTRAINT FK_74E0281CE69B7D2F FOREIGN KEY (classe_finale_id) REFERENCES classes (id) ON DELETE SET NULL');
        $this->addSql('ALTER TABLE classes ADD whatsapp_group_id VARCHAR(120) DEFAULT NULL, ADD whatsapp_group_invite_link VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE ecoles ADD whatsapp_instance_id VARCHAR(120) DEFAULT NULL, ADD whatsapp_api_token VARCHAR(255) DEFAULT NULL, ADD whatsapp_instance_active TINYINT DEFAULT 0 NOT NULL');
        $this->addSql('ALTER TABLE sections ADD whatsapp_group_id VARCHAR(120) DEFAULT NULL, ADD whatsapp_group_invite_link VARCHAR(255) DEFAULT NULL');
    }

    public function down(Schema $schema): void
    {
        // this down() migration is auto-generated, please modify it to your needs
        $this->addSql('ALTER TABLE etudiants DROP FOREIGN KEY FK_227C02EB77EF1B1E');
        $this->addSql('ALTER TABLE etudiants DROP FOREIGN KEY FK_227C02EBD823E37A');
        $this->addSql('ALTER TABLE etudiants DROP FOREIGN KEY FK_227C02EBB3E9C81');
        $this->addSql('ALTER TABLE etudiants DROP FOREIGN KEY FK_227C02EB8F5EA509');
        $this->addSql('ALTER TABLE inscriptions DROP FOREIGN KEY FK_74E0281C77EF1B1E');
        $this->addSql('ALTER TABLE inscriptions DROP FOREIGN KEY FK_74E0281CDDEAB1A3');
        $this->addSql('ALTER TABLE inscriptions DROP FOREIGN KEY FK_74E0281C8AAC02CD');
        $this->addSql('ALTER TABLE inscriptions DROP FOREIGN KEY FK_74E0281CEB809123');
        $this->addSql('ALTER TABLE inscriptions DROP FOREIGN KEY FK_74E0281CEB7D15A3');
        $this->addSql('ALTER TABLE inscriptions DROP FOREIGN KEY FK_74E0281CB5824D8D');
        $this->addSql('ALTER TABLE inscriptions DROP FOREIGN KEY FK_74E0281CAAD2DB9E');
        $this->addSql('ALTER TABLE inscriptions DROP FOREIGN KEY FK_74E0281CE69B7D2F');
        $this->addSql('DROP TABLE etudiants');
        $this->addSql('DROP TABLE inscriptions');
        $this->addSql('ALTER TABLE classes DROP whatsapp_group_id, DROP whatsapp_group_invite_link');
        $this->addSql('ALTER TABLE ecoles DROP whatsapp_instance_id, DROP whatsapp_api_token, DROP whatsapp_instance_active');
        $this->addSql('ALTER TABLE sections DROP whatsapp_group_id, DROP whatsapp_group_invite_link');
    }
}
