<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20230208145342 extends AbstractMigration
{
public function getDescription(): string
{
return 'update person_type to either physical or moral depending on the gender';
}
public function up(Schema $schema): void
{
$this->addSql("UPDATE abstract_people SET person_type = 'Moral' FROM abstract_people a
INNER JOIN gender g on a.gender_id = g.id
WHERE g.code = 'C' and a.id = abstract_people.id");
$this->addSql("UPDATE abstract_people SET person_type = 'Physical' FROM abstract_people a
INNER JOIN gender g on a.gender_id = g.id
WHERE g.code = 'F' or g.code = 'M' and a.id = abstract_people.id");
$this->addSql("UPDATE abstract_collaborator SET person_type = 'Moral' FROM abstract_collaborator a
INNER JOIN gender g on a.gender_id = g.id
WHERE g.code = 'C' and a.id = abstract_collaborator.id");
$this->addSql("UPDATE abstract_collaborator SET person_type = 'Physical' FROM abstract_collaborator a
INNER JOIN gender g on a.gender_id = g.id
WHERE g.code = 'F' or g.code = 'M' and a.id = abstract_collaborator.id");
}
}