addSql('CREATE TABLE photos_tag (photos_id INT NOT NULL, tag_id INT NOT NULL, PRIMARY KEY (photos_id, tag_id))'); $this->addSql('CREATE INDEX IDX_CBE2DE88301EC62 ON photos_tag (photos_id)'); $this->addSql('CREATE INDEX IDX_CBE2DE88BAD26311 ON photos_tag (tag_id)'); $this->addSql('ALTER TABLE photos_tag ADD CONSTRAINT FK_CBE2DE88301EC62 FOREIGN KEY (photos_id) REFERENCES photos (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE photos_tag ADD CONSTRAINT FK_CBE2DE88BAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id) ON DELETE CASCADE'); } public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs $this->addSql('ALTER TABLE photos_tag DROP CONSTRAINT FK_CBE2DE88301EC62'); $this->addSql('ALTER TABLE photos_tag DROP CONSTRAINT FK_CBE2DE88BAD26311'); $this->addSql('DROP TABLE photos_tag'); } }