migrations/Version20230521155054.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 Version20230521155054 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('CREATE TABLE image_gallery_content_resource (image_gallery_content_id INT NOT NULL, resource_id INT NOT NULL, PRIMARY KEY(image_gallery_content_id, resource_id))');
  19.         $this->addSql('CREATE INDEX IDX_E72ABB197E614D42 ON image_gallery_content_resource (image_gallery_content_id)');
  20.         $this->addSql('CREATE INDEX IDX_E72ABB1989329D25 ON image_gallery_content_resource (resource_id)');
  21.         $this->addSql('ALTER TABLE image_gallery_content_resource ADD CONSTRAINT FK_E72ABB197E614D42 FOREIGN KEY (image_gallery_content_id) REFERENCES image_gallery_content (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  22.         $this->addSql('ALTER TABLE image_gallery_content_resource ADD CONSTRAINT FK_E72ABB1989329D25 FOREIGN KEY (resource_id) REFERENCES resource (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  23.         $this->addSql('ALTER TABLE image_gallery_content_image_content DROP CONSTRAINT fk_bab62da17e614d42');
  24.         $this->addSql('ALTER TABLE image_gallery_content_image_content DROP CONSTRAINT fk_bab62da1e87eb4db');
  25.         $this->addSql('DROP TABLE image_gallery_content_image_content');
  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('CREATE TABLE image_gallery_content_image_content (image_gallery_content_id INT NOT NULL, image_content_id INT NOT NULL, PRIMARY KEY(image_gallery_content_id, image_content_id))');
  31.         $this->addSql('CREATE INDEX idx_bab62da1e87eb4db ON image_gallery_content_image_content (image_content_id)');
  32.         $this->addSql('CREATE INDEX idx_bab62da17e614d42 ON image_gallery_content_image_content (image_gallery_content_id)');
  33.         $this->addSql('ALTER TABLE image_gallery_content_image_content ADD CONSTRAINT fk_bab62da17e614d42 FOREIGN KEY (image_gallery_content_id) REFERENCES image_gallery_content (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  34.         $this->addSql('ALTER TABLE image_gallery_content_image_content ADD CONSTRAINT fk_bab62da1e87eb4db FOREIGN KEY (image_content_id) REFERENCES image_content (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
  35.         $this->addSql('ALTER TABLE image_gallery_content_resource DROP CONSTRAINT FK_E72ABB197E614D42');
  36.         $this->addSql('ALTER TABLE image_gallery_content_resource DROP CONSTRAINT FK_E72ABB1989329D25');
  37.         $this->addSql('DROP TABLE image_gallery_content_resource');
  38.     }
  39. }