From 1b65cac1dfa4a49ad1562848022e7fb4c836b822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 5 Dec 2024 15:16:46 +0100 Subject: [PATCH 1/2] Make person phone number nullable Removed the "not null" constraint from the person phone number field to allow for better flexibility in data storage, such as storing notes. This change rectifies issues in certain instances where the migration had incorrectly set the field to "not null". Adjustments include updating the database schema and modifying the entity definition to reflect this change. --- .../unreleased/Fixed-20241205-151629.yaml | 5 +++ .../migrations/Version20241205140905.php | 32 +++++++++++++++++++ .../ChillPersonBundle/Entity/PersonPhone.php | 8 +++-- .../migrations/Version20240918151852.php | 1 - 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 .changes/unreleased/Fixed-20241205-151629.yaml create mode 100644 src/Bundle/ChillMainBundle/migrations/Version20241205140905.php diff --git a/.changes/unreleased/Fixed-20241205-151629.yaml b/.changes/unreleased/Fixed-20241205-151629.yaml new file mode 100644 index 000000000..bf5c94b11 --- /dev/null +++ b/.changes/unreleased/Fixed-20241205-151629.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: Remove the "not null" constraint on person supplementary phones +time: 2024-12-05T15:16:29.001240887+01:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillMainBundle/migrations/Version20241205140905.php b/src/Bundle/ChillMainBundle/migrations/Version20241205140905.php new file mode 100644 index 000000000..2098865cf --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20241205140905.php @@ -0,0 +1,32 @@ +addSql('ALTER TABLE chill_person_phone ALTER phonenumber DROP NOT NULL'); + } + + public function down(Schema $schema): void {} +} diff --git a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php index 8edf4411a..78e1015b8 100644 --- a/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php +++ b/src/Bundle/ChillPersonBundle/Entity/PersonPhone.php @@ -20,7 +20,6 @@ use libphonenumber\PhoneNumber; #[ORM\Entity] #[ORM\Table(name: 'chill_person_phone')] #[ORM\Index(name: 'phonenumber', columns: ['phonenumber'])] -#[ORM\Index(name: 'phonenumber', columns: ['phonenumber'])] class PersonPhone { #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: false)] @@ -37,7 +36,12 @@ class PersonPhone #[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'otherPhoneNumbers')] private Person $person; - #[ORM\Column(type: 'phone_number', nullable: false)] + /** + * The phonenumber. + * + * This phonenumber is nullable: this allow user to store some notes instead of a phonenumber + */ + #[ORM\Column(type: 'phone_number', nullable: true)] private ?PhoneNumber $phonenumber = null; #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, length: 40, nullable: true)] diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20240918151852.php b/src/Bundle/ChillPersonBundle/migrations/Version20240918151852.php index 27827a86d..d7f37066e 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20240918151852.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20240918151852.php @@ -29,7 +29,6 @@ final class Version20240918151852 extends AbstractMigration $this->addSql('ALTER TABLE chill_person_accompanying_period_work_referrer ALTER id DROP DEFAULT'); $this->addSql('ALTER TABLE chill_person_household_composition_type ALTER label SET DEFAULT \'{}\''); $this->addSql('ALTER TABLE chill_person_household_composition_type ALTER label SET NOT NULL'); - $this->addSql('ALTER TABLE chill_person_phone ALTER phonenumber SET NOT NULL'); $this->addSql('ALTER TABLE chill_person_relationships ALTER createdby_id DROP NOT NULL'); $this->addSql('ALTER TABLE chill_person_relationships ALTER createdat DROP NOT NULL'); $this->addSql('ALTER TABLE chill_person_resource ALTER createdby_id DROP NOT NULL'); From 351e9c3fcc7964703d8d65b4845b9c8d2ecbf838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 5 Dec 2024 15:32:35 +0100 Subject: [PATCH 2/2] Remove custom join table configuration for documents The custom join table setup for the 'documents' relation has been removed. This change relies on the default naming and configuration provided by Doctrine, simplifying the code and reducing potential configuration errors. --- src/Bundle/ChillActivityBundle/Entity/Activity.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index 408c27ed8..4701d2483 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -84,11 +84,6 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac */ #[Assert\Valid(traverse: true)] #[ORM\ManyToMany(targetEntity: StoredObject::class, cascade: ['persist'])] - #[ORM\JoinTable( - name: 'activity_storedobject', - joinColumns: new ORM\JoinColumn(name: 'activity_id', referencedColumnName: 'id', nullable: false), - inverseJoinColumns: new ORM\InverseJoinColumn(name: 'storedobject_id', referencedColumnName: 'id', unique: true, nullable: false) - )] private Collection $documents; #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TIME_MUTABLE, nullable: true)]