migrations/Version20210107070954.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 Version20210107070954 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->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  19.         $this->addSql('ALTER TABLE reservation ADD lot_id INT DEFAULT NULL');
  20.         $this->addSql('update reservation set lot_id = (SELECT lot.id FROM lot, planning WHERE lot.aquereur_id = reservation.user_id AND planning.id= reservation.planning_id AND planning.programme_id = lot.programme_id )');
  21.         $this->addSql('ALTER TABLE reservation ADD CONSTRAINT FK_42C84955A8CBA5F7 FOREIGN KEY (lot_id) REFERENCES lot (id)');
  22.         $this->addSql('CREATE UNIQUE INDEX UNIQ_42C84955A8CBA5F7 ON reservation (lot_id)');
  23.         $this->addSql('ALTER TABLE programme CHANGE user_id user_id INT DEFAULT NULL');
  24.         $this->addSql('ALTER TABLE reservation CHANGE lot_id lot_id INT NOT NULL');
  25.         $this->addSql('ALTER TABLE planning DROP INDEX UNIQ_D499BFF662BB7AEE, ADD INDEX IDX_D499BFF662BB7AEE (programme_id)');
  26.         $this->addSql('ALTER TABLE planning ADD name VARCHAR(255) NOT NULL, ADD close TINYINT(1) NOT NULL');
  27.     }
  28.     public function down(Schema $schema): void
  29.     {
  30.         // this down() migration is auto-generated, please modify it to your needs
  31.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql''Migration can only be executed safely on \'mysql\'.');
  32.         $this->addSql('ALTER TABLE planning DROP INDEX IDX_D499BFF662BB7AEE, ADD UNIQUE INDEX UNIQ_D499BFF662BB7AEE (programme_id)');
  33.         $this->addSql('ALTER TABLE planning DROP name, DROP close');
  34.         $this->addSql('ALTER TABLE programme CHANGE user_id user_id INT NOT NULL');
  35.         $this->addSql('ALTER TABLE reservation CHANGE lot_id lot_id INT DEFAULT NULL');
  36.         $this->addSql('ALTER TABLE reservation DROP FOREIGN KEY FK_42C84955A8CBA5F7');
  37.         $this->addSql('DROP INDEX UNIQ_42C84955A8CBA5F7 ON reservation');
  38.         $this->addSql('ALTER TABLE reservation DROP lot_id');
  39.     }
  40. }