migrations/Version20230515121445.php line 1

  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 Version20230515121445 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 site DROP CONSTRAINT fk_694309e4fdff2e92');
  19.         $this->addSql('DROP INDEX uniq_694309e4fdff2e92');
  20.         $this->addSql('ALTER TABLE site RENAME COLUMN thumbnail_id TO creator_id');
  21.         $this->addSql('ALTER TABLE site ADD CONSTRAINT FK_694309E461220EA6 FOREIGN KEY (creator_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  22.         $this->addSql('CREATE INDEX IDX_694309E461220EA6 ON site (creator_id)');
  23.         $this->addSql('ALTER TABLE "user" DROP CONSTRAINT fk_8d93d649f6bd1646');
  24.         $this->addSql('DROP INDEX uniq_8d93d649f6bd1646');
  25.         $this->addSql('ALTER TABLE "user" DROP site_id');
  26.     }
  27.     public function down(Schema $schema): void
  28.     {
  29.         // this down() migration is auto-generated, please modify it to your needs
  30.         $this->addSql('ALTER TABLE site DROP CONSTRAINT FK_694309E461220EA6');
  31.         $this->addSql('DROP INDEX IDX_694309E461220EA6');
  32.         $this->addSql('ALTER TABLE site RENAME COLUMN creator_id TO thumbnail_id');
  33.         $this->addSql('ALTER TABLE site ADD CONSTRAINT fk_694309e4fdff2e92 FOREIGN KEY (thumbnail_id) REFERENCES resource (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  34.         $this->addSql('CREATE UNIQUE INDEX uniq_694309e4fdff2e92 ON site (thumbnail_id)');
  35.         $this->addSql('ALTER TABLE "user" ADD site_id INT DEFAULT NULL');
  36.         $this->addSql('ALTER TABLE "user" ADD CONSTRAINT fk_8d93d649f6bd1646 FOREIGN KEY (site_id) REFERENCES site (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  37.         $this->addSql('CREATE UNIQUE INDEX uniq_8d93d649f6bd1646 ON "user" (site_id)');
  38.     }
  39. }