FEATURE [profession] change field type of profession into string

This commit is contained in:
Julie Lenaerts 2023-02-15 20:08:04 +01:00 committed by Julien Fastré
parent c953da3fd0
commit ac4c821290
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 34 additions and 8 deletions

View File

@ -250,14 +250,11 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
/**
* [fr] Qualité.
*
* @var ThirdPartyProfession
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdPartyProfession")
* ORM\JoinColumn(name="profession", referencedColumnName="id", nullable=true)
* @ORM\Column(name="profession", type="string", length=255, nullable=false)
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
* @Context(normalizationContext={"groups": "docgen:read"}, groups={"docgen:read:3party:parent"})
*/
private ?ThirdPartyProfession $profession = null;
private string $profession = '';
/**
* @ORM\Column(name="telephone", type="phone_number", nullable=true)
@ -491,9 +488,9 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
}
/**
* @return ThirdPartyProfession
* @return string
*/
public function getProfession(): ?ThirdPartyProfession
public function getProfession(): string
{
return $this->profession;
}
@ -811,7 +808,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
/**
* @return $this
*/
public function setProfession(?ThirdPartyProfession $profession): ThirdParty
public function setProfession(string $profession): self
{
$this->profession = $profession;

View File

@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\ThirdParty;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20230215175150 extends AbstractMigration
{
public function getDescription(): string
{
return 'Change profession to a string field and transfer values';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_3party.third_party ADD profession VARCHAR(255) DEFAULT \'\' NOT NULL');
// $this->addSql('ALTER TABLE chill_3party.third_party DROP profession_id');
}
public function down(Schema $schema): void
{
// $this->addSql('ALTER TABLE chill_3party.third_party ADD profession_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_3party.third_party DROP profession');
}
}