diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php index 3dc205f09..2486d1fcc 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php @@ -14,6 +14,7 @@ namespace Chill\AsideActivityBundle\Entity; use Chill\MainBundle\Doctrine\Model\TrackCreationInterface; use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; use Chill\MainBundle\Entity\User; +use Chill\MainBundle\Entity\Location; use DateTimeInterface; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; @@ -60,9 +61,10 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface private ?int $id = null; /** - * @ORM\Column(type="string", length=100, nullable=true) + * @ORM\ManyToOne(targetEntity=Location::class) + * @ORM\JoinColumn(nullable=true) */ - private $location; + private ?Location $location; /** * @ORM\Column(type="text", nullable=true) @@ -115,7 +117,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface return $this->id; } - public function getLocation(): ?string + public function getLocation(): ?Location { return $this->location; } @@ -175,7 +177,7 @@ class AsideActivity implements TrackCreationInterface, TrackUpdateInterface return $this; } - public function setLocation(?string $location): self + public function setLocation(?Location $location): self { $this->location = $location; diff --git a/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20230816112809.php b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20230816112809.php new file mode 100644 index 000000000..6a52f41f9 --- /dev/null +++ b/src/Bundle/ChillAsideActivityBundle/src/migrations/Version20230816112809.php @@ -0,0 +1,35 @@ +addSql('DROP INDEX chill_asideactivity.IDX_A866DA0E64D218E'); + $this->addSql('ALTER TABLE chill_asideactivity.AsideActivity DROP CONSTRAINT FK_A866DA0E64D218E'); + $this->addSql('ALTER TABLE chill_asideactivity.AsideActivity DROP location_id'); + $this->addSql('ALTER TABLE chill_asideactivity.AsideActivity ADD location VARCHAR(100) DEFAULT NULL'); + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_asideactivity.asideactivity ADD location_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_asideactivity.asideactivity DROP location'); + $this->addSql('ALTER TABLE chill_asideactivity.asideactivity ADD CONSTRAINT FK_A866DA0E64D218E FOREIGN KEY (location_id) REFERENCES chill_main_location (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_A866DA0E64D218E ON chill_asideactivity.asideactivity (location_id)'); + } +}