<?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 Version20240404100504 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('ALTER TABLE prospect ADD entreprise_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE programme ADD entreprise_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE prospect ADD CONSTRAINT FK_C9CE8C7DA4AEAFEA FOREIGN KEY (entreprise_id) REFERENCES entreprise (id)');
$this->addSql('ALTER TABLE programme ADD CONSTRAINT FK_3DDCB9FFA4AEAFEA FOREIGN KEY (entreprise_id) REFERENCES entreprise (id)');
$this->addSql('CREATE INDEX IDX_C9CE8C7DA4AEAFEA ON prospect (entreprise_id)');
$this->addSql('CREATE INDEX IDX_3DDCB9FFA4AEAFEA ON programme (entreprise_id)');
// Insert new entreprise
$this->addSql("INSERT INTO entreprise (nom, email) VALUES ('LK1 IMMOBILIER', 'ebala@lk1.fr')");
// Set entreprise_id to 1 for all rows in utilisateur, prospect and programme tables
$this->addSql('UPDATE utilisateur SET entreprise_id = 1');
$this->addSql('UPDATE prospect SET entreprise_id = 1');
$this->addSql('UPDATE programme SET entreprise_id = 1');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE programme DROP FOREIGN KEY FK_3DDCB9FFA4AEAFEA');
$this->addSql('ALTER TABLE prospect DROP FOREIGN KEY FK_C9CE8C7DA4AEAFEA');
$this->addSql('DROP INDEX IDX_3DDCB9FFA4AEAFEA ON programme');
$this->addSql('DROP INDEX IDX_C9CE8C7DA4AEAFEA ON prospect');
$this->addSql('ALTER TABLE programme DROP entreprise_id');
$this->addSql('ALTER TABLE prospect CHANGE entreprise_id entreprise_id INT NOT NULL');
// Delete the newly added entreprise
$this->addSql("DELETE FROM entreprise WHERE nom = 'LK1 IMMOBILIER' AND email = 'ebala@lk1.fr'");
}
}