migrations/Version20230605154617.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 Version20230605154617 extends AbstractMigration
  7. {
  8.     public function getDescription(): string
  9.     {
  10.         return 'Added default avatar to collaborators';
  11.     }
  12.     public function up(Schema $schema): void
  13.     {
  14.         // Insert avatar for agent with Morale person type
  15.         $this->addSql("INSERT INTO avatar (id, collaborator_id, file_path)
  16.                             SELECT nextval('avatar_id_seq'), c.id, 'avatar-c.png'
  17.                             FROM abstract_collaborator c
  18.                             LEFT JOIN avatar a ON c.id = a.collaborator_id
  19.                             WHERE a.collaborator_id IS NULL and c.person_type = 'Moral'");
  20.         // Insert avatar for female agents
  21.         $this->addSql("INSERT INTO avatar (id, collaborator_id, file_path)
  22.                             SELECT nextval('avatar_id_seq'), c.id, 'avatar-f.png'
  23.                             FROM abstract_collaborator c
  24.                             LEFT JOIN avatar a ON c.id = a.collaborator_id
  25.                             inner join gender g on g.id = c.gender_id
  26.                             WHERE a.collaborator_id IS NULL and (c.person_type != 'Moral' or c.person_type is null ) 
  27.                             and g.code = 'F'");
  28.         // Insert avatar for male agents
  29.         $this->addSql("INSERT INTO avatar (id, collaborator_id, file_path)
  30.                             SELECT nextval('avatar_id_seq'), c.id, 'avatar-m.png'
  31.                             FROM abstract_collaborator c
  32.                             LEFT JOIN avatar a ON c.id = a.collaborator_id
  33.                             inner join gender g on g.id = c.gender_id
  34.                             WHERE a.collaborator_id IS NULL and (c.person_type != 'Moral' or c.person_type is null ) 
  35.                             and g.code = 'M'");
  36.     }
  37. }