forum/migrations/Version20250212203002.php

43 lines
1.8 KiB
PHP
Raw Normal View History

2025-02-13 13:39:42 +03: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 Version20250212203002 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 branch (id SERIAL NOT NULL, theme_id INT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_BB861B1F59027487 ON branch (theme_id)');
$this->addSql('CREATE TABLE message (id SERIAL NOT NULL, branch_id INT NOT NULL, text TEXT NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_B6BD307FDCD6CC49 ON message (branch_id)');
$this->addSql('CREATE TABLE theme (id SERIAL NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('ALTER TABLE branch ADD CONSTRAINT FK_BB861B1F59027487 FOREIGN KEY (theme_id) REFERENCES theme (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE message ADD CONSTRAINT FK_B6BD307FDCD6CC49 FOREIGN KEY (branch_id) REFERENCES branch (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE branch DROP CONSTRAINT FK_BB861B1F59027487');
$this->addSql('ALTER TABLE message DROP CONSTRAINT FK_B6BD307FDCD6CC49');
$this->addSql('DROP TABLE branch');
$this->addSql('DROP TABLE message');
$this->addSql('DROP TABLE theme');
}
}