migrations/Version20240404100504.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 Version20240404100504 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('ALTER TABLE prospect ADD entreprise_id INT DEFAULT NULL');
  19.         $this->addSql('ALTER TABLE programme ADD entreprise_id INT DEFAULT NULL');
  20.         $this->addSql('ALTER TABLE prospect ADD CONSTRAINT FK_C9CE8C7DA4AEAFEA FOREIGN KEY (entreprise_id) REFERENCES entreprise (id)');
  21.         $this->addSql('ALTER TABLE programme ADD CONSTRAINT FK_3DDCB9FFA4AEAFEA FOREIGN KEY (entreprise_id) REFERENCES entreprise (id)');
  22.         $this->addSql('CREATE INDEX IDX_C9CE8C7DA4AEAFEA ON prospect (entreprise_id)');
  23.         $this->addSql('CREATE INDEX IDX_3DDCB9FFA4AEAFEA ON programme (entreprise_id)');
  24.         // Insert new entreprise
  25.         $this->addSql("INSERT INTO entreprise (nom, email) VALUES ('LK1 IMMOBILIER', 'ebala@lk1.fr')");
  26.         // Set entreprise_id to 1 for all rows in utilisateur, prospect and programme tables
  27.         $this->addSql('UPDATE utilisateur SET entreprise_id = 1');
  28.         $this->addSql('UPDATE prospect SET entreprise_id = 1');
  29.         $this->addSql('UPDATE programme SET entreprise_id = 1');
  30.     }
  31.     public function down(Schema $schema): void
  32.     {
  33.         // this down() migration is auto-generated, please modify it to your needs
  34.         $this->addSql('ALTER TABLE programme DROP FOREIGN KEY FK_3DDCB9FFA4AEAFEA');
  35.         $this->addSql('ALTER TABLE prospect DROP FOREIGN KEY FK_C9CE8C7DA4AEAFEA');
  36.         $this->addSql('DROP INDEX IDX_3DDCB9FFA4AEAFEA ON programme');
  37.         $this->addSql('DROP INDEX IDX_C9CE8C7DA4AEAFEA ON prospect');
  38.         $this->addSql('ALTER TABLE programme DROP entreprise_id');
  39.         $this->addSql('ALTER TABLE prospect CHANGE entreprise_id entreprise_id INT NOT NULL');
  40.         // Delete the newly added entreprise
  41.         $this->addSql("DELETE FROM entreprise WHERE nom = 'LK1 IMMOBILIER' AND email = 'ebala@lk1.fr'");
  42.     }
  43. }