<?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 Version20220927100559 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 file (id SERIAL NOT NULL, created_by_id INT NOT NULL, filename VARCHAR(255) NOT NULL, path VARCHAR(255) DEFAULT NULL, original_filename VARCHAR(255) NOT NULL, alt VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_8C9F3610B03A8386 ON file (created_by_id)');
$this->addSql('COMMENT ON TABLE file IS \'Файлы\'');
$this->addSql('COMMENT ON COLUMN file.filename IS \'Имя файла\'');
$this->addSql('COMMENT ON COLUMN file.path IS \'Путь к файлу\'');
$this->addSql('COMMENT ON COLUMN file.original_filename IS \'Оригинальное имя файла\'');
$this->addSql('COMMENT ON COLUMN file.alt IS \'Аттрибут Alt\'');
$this->addSql('ALTER TABLE file ADD CONSTRAINT FK_8C9F3610B03A8386 FOREIGN KEY (created_by_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE news ADD file_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE news ADD CONSTRAINT FK_1DD3995093CB796C FOREIGN KEY (file_id) REFERENCES file (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_1DD3995093CB796C ON news (file_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE news DROP CONSTRAINT FK_1DD3995093CB796C');
$this->addSql('ALTER TABLE file DROP CONSTRAINT FK_8C9F3610B03A8386');
$this->addSql('DROP TABLE file');
$this->addSql('DROP INDEX IDX_1DD3995093CB796C');
$this->addSql('ALTER TABLE news DROP file_id');
}
}