alexdaniels.me/migrations/Version20260608193439.php

38 lines
1.4 KiB
PHP
Raw Normal View History

2026-06-08 13:00:11 -07:00
<?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 Version20260608193439 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('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');
}
}