<?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 Version20220930141916 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('ALTER TABLE news DROP CONSTRAINT fk_1dd3995012469de2');
$this->addSql('DROP SEQUENCE IF EXISTS category_id_seq CASCADE');
$this->addSql('DROP SEQUENCE IF EXISTS category_id_seq1 CASCADE');
$this->addSql('CREATE TABLE news_category (id SERIAL NOT NULL, created_by_id INT NOT NULL, name VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_4F72BA90B03A8386 ON news_category (created_by_id)');
$this->addSql('COMMENT ON TABLE news_category IS \'Категории\'');
$this->addSql('COMMENT ON COLUMN news_category.name IS \'Наименование\'');
$this->addSql('CREATE TABLE sport (id SERIAL NOT NULL, file_id INT DEFAULT NULL, created_by_id INT NOT NULL, name VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_1A85EFD293CB796C ON sport (file_id)');
$this->addSql('CREATE INDEX IDX_1A85EFD2B03A8386 ON sport (created_by_id)');
$this->addSql('COMMENT ON TABLE sport IS \'Виды спорта\'');
$this->addSql('COMMENT ON COLUMN sport.name IS \'Наименование\'');
$this->addSql('CREATE TABLE sport_object_category (id SERIAL NOT NULL, created_by_id INT NOT NULL, name VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_6FFC2400B03A8386 ON sport_object_category (created_by_id)');
$this->addSql('COMMENT ON TABLE sport_object_category IS \'Категория спортивных объектов\'');
$this->addSql('ALTER TABLE news_category ADD CONSTRAINT FK_4F72BA90B03A8386 FOREIGN KEY (created_by_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE sport ADD CONSTRAINT FK_1A85EFD293CB796C FOREIGN KEY (file_id) REFERENCES file (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE sport ADD CONSTRAINT FK_1A85EFD2B03A8386 FOREIGN KEY (created_by_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE sport_object_category ADD CONSTRAINT FK_6FFC2400B03A8386 FOREIGN KEY (created_by_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE category DROP CONSTRAINT fk_64c19c1b03a8386');
$this->addSql('DROP TABLE category');
$this->addSql('DROP INDEX idx_1dd3995012469de2');
$this->addSql('ALTER TABLE news RENAME COLUMN category_id TO news_category_id');
$this->addSql('ALTER TABLE news ADD CONSTRAINT FK_1DD399503B732BAD FOREIGN KEY (news_category_id) REFERENCES news_category (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_1DD399503B732BAD ON news (news_category_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
}