<?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 Version20231127101031 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 phone (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, phone_number VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_444F97DDA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE phone ADD CONSTRAINT FK_444F97DDA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE user_file_person ADD phone_object_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE user_file_person ADD CONSTRAINT FK_25D03E5C2A535D13 FOREIGN KEY (phone_object_id) REFERENCES phone (id)');
$this->addSql('CREATE INDEX IDX_25D03E5C2A535D13 ON user_file_person (phone_object_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user_file_person DROP FOREIGN KEY FK_25D03E5C2A535D13');
$this->addSql('ALTER TABLE phone DROP FOREIGN KEY FK_444F97DDA76ED395');
$this->addSql('DROP TABLE phone');
$this->addSql('DROP INDEX IDX_25D03E5C2A535D13 ON user_file_person');
$this->addSql('ALTER TABLE user_file_person DROP phone_object_id');
}
}