<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20230611124626 extends AbstractMigration
{
public function getDescription(): string
{
return 'Regions table';
}
public function up(Schema $schema): void
{
$this->addSql("
CREATE TABLE `region` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`parent_id` int UNSIGNED NULL,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`) )
");
$this->addSql("
ALTER TABLE `region`
ADD CONSTRAINT `parent_id` FOREIGN KEY (`parent_id`) REFERENCES `region` (`id`)
");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE IF EXISTS `region`");
}
}