<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20261026170000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add nullable created_by on attachment so API uploads can be limited to their owner.';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE attachment ADD created_by UUID DEFAULT NULL');
$this->addSql('COMMENT ON COLUMN attachment.created_by IS \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE attachment ADD CONSTRAINT FK_ATTACHMENT_CREATED_BY FOREIGN KEY (created_by) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_ATTACHMENT_CREATED_BY ON attachment (created_by)');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE attachment DROP CONSTRAINT FK_ATTACHMENT_CREATED_BY');
$this->addSql('DROP INDEX IDX_ATTACHMENT_CREATED_BY');
$this->addSql('ALTER TABLE attachment DROP created_by');
}
}