Merge branch '342-error-while-deploying-chill-version-v3-4-2-migrations-are-blocked' into 'master'

Resolve "Error while deploying chill version v3.4.2: migrations are blocked"

Closes #342

See merge request Chill-Projet/chill-bundles!770
This commit is contained in:
Julien Fastré 2024-12-05 14:33:34 +00:00
commit 6c4d8990cc
5 changed files with 43 additions and 8 deletions

View File

@ -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: ""

View File

@ -84,11 +84,6 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
*/ */
#[Assert\Valid(traverse: true)] #[Assert\Valid(traverse: true)]
#[ORM\ManyToMany(targetEntity: StoredObject::class, cascade: ['persist'])] #[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; private Collection $documents;
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TIME_MUTABLE, nullable: true)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TIME_MUTABLE, nullable: true)]

View File

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20241205140905 extends AbstractMigration
{
public function getDescription(): string
{
return 'Restore the nullable person phone, as this is used by comments';
}
public function up(Schema $schema): void
{
// this should be already not null, but helps some instances, where a migration which drop not null
// was executed, and was wrong.
$this->addSql('ALTER TABLE chill_person_phone ALTER phonenumber DROP NOT NULL');
}
public function down(Schema $schema): void {}
}

View File

@ -20,7 +20,6 @@ use libphonenumber\PhoneNumber;
#[ORM\Entity] #[ORM\Entity]
#[ORM\Table(name: 'chill_person_phone')] #[ORM\Table(name: 'chill_person_phone')]
#[ORM\Index(name: 'phonenumber', columns: ['phonenumber'])] #[ORM\Index(name: 'phonenumber', columns: ['phonenumber'])]
#[ORM\Index(name: 'phonenumber', columns: ['phonenumber'])]
class PersonPhone class PersonPhone
{ {
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: false)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_MUTABLE, nullable: false)]
@ -37,7 +36,12 @@ class PersonPhone
#[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'otherPhoneNumbers')] #[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'otherPhoneNumbers')]
private Person $person; 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; private ?PhoneNumber $phonenumber = null;
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, length: 40, nullable: true)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, length: 40, nullable: true)]

View File

@ -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_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 DEFAULT \'{}\'');
$this->addSql('ALTER TABLE chill_person_household_composition_type ALTER label SET NOT NULL'); $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 createdby_id DROP NOT NULL');
$this->addSql('ALTER TABLE chill_person_relationships ALTER createdat 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'); $this->addSql('ALTER TABLE chill_person_resource ALTER createdby_id DROP NOT NULL');