migrations/Version20230208145342.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. final class Version20230208145342 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'update person_type to either physical or moral depending on the gender';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         $this->addSql("UPDATE abstract_people SET person_type = 'Moral' FROM abstract_people a
  15.                                 INNER JOIN gender g on a.gender_id = g.id
  16.                                 WHERE g.code = 'C' and a.id = abstract_people.id");
  17.         $this->addSql("UPDATE abstract_people SET person_type = 'Physical' FROM abstract_people a
  18.                                 INNER JOIN gender g on a.gender_id = g.id
  19.                                 WHERE g.code = 'F' or g.code = 'M' and a.id = abstract_people.id");
  20.         $this->addSql("UPDATE abstract_collaborator SET person_type = 'Moral' FROM abstract_collaborator a
  21.                                 INNER JOIN gender g on a.gender_id = g.id
  22.                                 WHERE g.code = 'C' and a.id = abstract_collaborator.id");
  23.         $this->addSql("UPDATE abstract_collaborator SET person_type = 'Physical' FROM abstract_collaborator a
  24.                                 INNER JOIN gender g on a.gender_id = g.id
  25.                                 WHERE g.code = 'F' or g.code = 'M' and a.id = abstract_collaborator.id");
  26.     }
  27. }