<?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 Version20240315170404 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 materials ADD region_id INT DEFAULT NULL, DROP region');
$this->addSql('ALTER TABLE materials ADD CONSTRAINT FK_9B1716B598260155 FOREIGN KEY (region_id) REFERENCES countries (id)');
$this->addSql('CREATE INDEX IDX_9B1716B598260155 ON materials (region_id)');
$this->addSql('ALTER TABLE user_history DROP FOREIGN KEY FK_7FB76E41E308AC6F');
$this->addSql('ALTER TABLE user_history ADD CONSTRAINT FK_7FB76E41E308AC6F FOREIGN KEY (material_id) REFERENCES materials (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE materials DROP FOREIGN KEY FK_9B1716B598260155');
$this->addSql('DROP INDEX IDX_9B1716B598260155 ON materials');
$this->addSql('ALTER TABLE materials ADD region VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, DROP region_id');
$this->addSql('ALTER TABLE user_history DROP FOREIGN KEY FK_7FB76E41E308AC6F');
$this->addSql('ALTER TABLE user_history ADD CONSTRAINT FK_7FB76E41E308AC6F FOREIGN KEY (material_id) REFERENCES materials (id) ON DELETE CASCADE');
}
}