DX: [Address] fix inconsistencies between doctrine mapping and sql schema

DX: [Address] fix inconsistencies between doctrine mapping and sql schema

Fixed: Address vue module do now set empty value to empty string instead of null

DX: fixed AddressReferenceBaseImporterTest
This commit is contained in:
Julien Fastré 2023-03-06 16:18:15 +01:00
parent 8e0d144dd1
commit c9fe5a393f
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
8 changed files with 305 additions and 157 deletions

View File

@ -61,67 +61,48 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
private ?AddressReference $addressReference = null;
/**
* @var string|null
*
* @ORM\Column(type="string", length=255, nullable=true)
* @ORM\Column(type="text", nullable=false, options={"default": ""})
* @Groups({"write"})
*/
private string $buildingName = '';
/**
* @ORM\Column(type="boolean")
* @ORM\Column(type="boolean", options={"default": false})
* @Groups({"write"})
*/
private bool $confidential = false;
/**
* @var string|null
*
* @ORM\Column(type="string", length=255, nullable=true)
* @ORM\Column(type="text", nullable=false, options={"default": ""})
* @Groups({"write"})
*/
private $corridor;
private string $corridor = '';
/**
* A list of metadata, added by customizable fields.
*
* @var array
*/
private $customs = [];
/**
* @var string|null
*
* used for the CEDEX information
*
* @ORM\Column(type="string", length=255, nullable=true)
* @ORM\Column(type="text", nullable=false, options={"default": ""})
* @Groups({"write"})
*/
private $distribution;
private string $distribution = '';
/**
* @var string|null
*
* @ORM\Column(type="string", length=255, nullable=true)
* @ORM\Column(type="text", nullable=false, options={"default": ""})
* @Groups({"write"})
*/
private $extra;
private string $extra = '';
/**
* @var string|null
*
* @ORM\Column(type="string", length=255, nullable=true)
* @ORM\Column(type="text", nullable=false, options={"default": ""})
* @Groups({"write"})
*/
private $flat;
private string $flat = '';
/**
* @var string|null
*
* @ORM\Column(type="string", length=255, nullable=true)
* @ORM\Column(type="text", nullable=false, options={"default": ""})
* @Groups({"write"})
*/
private $floor;
private string $floor = '';
/**
* List of geographical units and addresses.
@ -155,11 +136,9 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* True if the address is a "no address", aka homeless person, ...
*
* @Groups({"write"})
* @ORM\Column(type="boolean")
*
* @var bool
* @ORM\Column(type="boolean", options={"default": false})
*/
private $isNoAddress = false;
private bool $isNoAddress = false;
/**
* A ThirdParty reference for person's addresses that are linked to a third party.
@ -170,7 +149,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* @Groups({"write"})
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/
private $linkedToThirdParty;
private ?ThirdParty $linkedToThirdParty;
/**
* A geospatial field storing the coordinates of the Address.
@ -180,7 +159,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* @ORM\Column(type="point", nullable=true)
* @Groups({"write"})
*/
private $point;
private ?Point $point = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
@ -201,28 +180,25 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
private \DateTimeImmutable $refStatusLastUpdate;
/**
* @var string|null
*
* @ORM\Column(type="string", length=255, nullable=true)
* @ORM\Column(type="text", nullable=false, options={"default": ""})
* @Groups({"write"})
*/
private $steps;
private string $steps = '';
/**
* @var string
*
* @ORM\Column(type="string", length=255)
* @ORM\Column(type="text", nullable=false, options={"default": ""})
* @Groups({"write"})
*/
private $street = '';
private string $street = '';
/**
* @var string
*
* @ORM\Column(type="string", length=255)
* @ORM\Column(type="text", nullable=false, options={"default": ""})
* @Groups({"write"})
*/
private $streetNumber = '';
private string $streetNumber = '';
/**
* Indicates when the address starts validation. Used to build an history
@ -256,7 +232,6 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
->setBuildingName($original->getBuildingName())
->setConfidential($original->getConfidential())
->setCorridor($original->getCorridor())
->setCustoms($original->getCustoms())
->setDistribution($original->getDistribution())
->setExtra($original->getExtra())
->setFlat($original->getFlat())
@ -287,7 +262,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
return $this->addressReference;
}
public function getBuildingName(): ?string
public function getBuildingName(): string
{
return $this->buildingName;
}
@ -297,35 +272,27 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
return $this->confidential;
}
public function getCorridor(): ?string
public function getCorridor(): string
{
return $this->corridor;
}
/**
* Get customs informations in the address.
*/
public function getCustoms(): array
{
return $this->customs;
}
public function getDistribution(): ?string
public function getDistribution(): string
{
return $this->distribution;
}
public function getExtra(): ?string
public function getExtra(): string
{
return $this->extra;
}
public function getFlat(): ?string
public function getFlat(): string
{
return $this->flat;
}
public function getFloor(): ?string
public function getFloor(): string
{
return $this->floor;
}
@ -376,12 +343,22 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
return $this->postcode;
}
public function getSteps(): ?string
public function getRefStatus(): string
{
return $this->refStatus;
}
public function getRefStatusLastUpdate(): \DateTimeImmutable
{
return $this->refStatusLastUpdate;
}
public function getSteps(): string
{
return $this->steps;
}
public function getStreet(): ?string
public function getStreet(): string
{
return $this->street;
}
@ -390,6 +367,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* Get streetAddress1 (legacy function).
*
* @return string
* @deprecated
*/
public function getStreetAddress1()
{
@ -400,13 +378,14 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* Get streetAddress2 (legacy function).
*
* @return string
* @deprecated
*/
public function getStreetAddress2()
{
return $this->streetNumber;
}
public function getStreetNumber(): ?string
public function getStreetNumber(): string
{
return $this->streetNumber;
}
@ -414,7 +393,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
/**
* @return DateTime
*/
public function getValidFrom()
public function getValidFrom(): DateTime
{
return $this->validFrom;
}
@ -443,7 +422,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
public function setBuildingName(?string $buildingName): self
{
$this->buildingName = $buildingName;
$this->buildingName = (string) $buildingName;
return $this;
}
@ -457,47 +436,35 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
public function setCorridor(?string $corridor): self
{
$this->corridor = $corridor;
return $this;
}
/**
* Store custom informations in the address.
*
* @return $this
*/
public function setCustoms(array $customs): self
{
$this->customs = $customs;
$this->corridor = (string) $corridor;
return $this;
}
public function setDistribution(?string $distribution): self
{
$this->distribution = $distribution;
$this->distribution = (string) $distribution;
return $this;
}
public function setExtra(?string $extra): self
{
$this->extra = $extra;
$this->extra = (string) $extra;
return $this;
}
public function setFlat(?string $flat): self
{
$this->flat = $flat;
$this->flat = (string) $flat;
return $this;
}
public function setFloor(?string $floor): self
{
$this->floor = $floor;
$this->floor = (string) $floor;
return $this;
}
@ -544,19 +511,40 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
/**
* Update the ref status
*
* @param Address::ADDR_REFERENCE_STATUS_* $refStatus
* @param bool|null $updateLastUpdate Also update the "refStatusLastUpdate"
*/
public function setRefStatus(string $refStatus, ?bool $updateLastUpdate = true): self
{
$this->refStatus = $refStatus;
if ($updateLastUpdate) {
$this->setRefStatusLastUpdate(new \DateTimeImmutable('now'));
}
return $this;
}
public function setRefStatusLastUpdate(\DateTimeImmutable $refStatusLastUpdate): self
{
$this->refStatusLastUpdate = $refStatusLastUpdate;
return $this;
}
public function setSteps(?string $steps): self
{
$this->steps = $steps;
$this->steps = (string) $steps;
return $this;
}
public function setStreet(?string $street): self
{
if (null === $street) {
$street = '';
}
$this->street = $street;
$this->street = (string) $street;
return $this;
}
@ -567,6 +555,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* @param string $streetAddress1
*
* @return Address
* @deprecated
*/
public function setStreetAddress1($streetAddress1)
{
@ -579,7 +568,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
* Set streetAddress2 (legacy function).
*
* @param string $streetAddress2
*
* @deprecated
* @return Address
*/
public function setStreetAddress2($streetAddress2)
@ -591,10 +580,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
public function setStreetNumber(?string $streetNumber): self
{
if (null === $streetNumber) {
$streetNumber = '';
}
$this->streetNumber = $streetNumber;
$this->streetNumber = (string) $streetNumber;
return $this;
}
@ -641,7 +627,7 @@ class Address implements TrackCreationInterface, TrackUpdateInterface
return;
}
if (empty($this->getStreetAddress1())) {
if ('' === $this->getStreet()) {
$context
->buildViolation('address.street1-should-be-set')
->atPath('streetAddress1')

View File

@ -55,13 +55,13 @@ class AddressReference
* @ORM\Column(type="integer")
* @groups({"read"})
*/
private $id;
private ?int $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @ORM\Column(type="text", nullable=false, options={"default": ""})
* @groups({"read"})
*/
private $municipalityCode;
private string $municipalityCode = '';
/**
* A geospatial field storing the coordinates of the Address.
@ -71,7 +71,7 @@ class AddressReference
* @ORM\Column(type="point")
* @groups({"read"})
*/
private $point;
private ?Point $point = null;
/**
* @var PostalCode
@ -79,31 +79,31 @@ class AddressReference
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
* @groups({"read"})
*/
private $postcode;
private ?PostalCode $postcode;
/**
* @ORM\Column(type="string", length=255)
* @ORM\Column(type="text", nullable=false, options={"default": ""})
* @groups({"read"})
*/
private $refId;
private string $refId = '';
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @ORM\Column(type="text", nullable=false, options={"default": ""})
* @groups({"read"})
*/
private $source;
private string $source = '';
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @ORM\Column(type="text", nullable=false, options={"default": ""})
* @groups({"read"})
*/
private $street;
private string $street = '';
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @ORM\Column(type="text", nullable=false, options={"default": ""})
* @groups({"read"})
*/
private $streetNumber;
private string $streetNumber = '';
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
@ -126,7 +126,7 @@ class AddressReference
return $this->id;
}
public function getMunicipalityCode(): ?string
public function getMunicipalityCode(): string
{
return $this->municipalityCode;
}
@ -141,27 +141,27 @@ class AddressReference
*
* @return PostalCode
*/
public function getPostcode()
public function getPostcode(): ?PostalCode
{
return $this->postcode;
}
public function getRefId(): ?string
public function getRefId(): string
{
return $this->refId;
}
public function getSource(): ?string
public function getSource(): string
{
return $this->source;
}
public function getStreet(): ?string
public function getStreet(): string
{
return $this->street;
}
public function getStreetNumber(): ?string
public function getStreetNumber(): string
{
return $this->streetNumber;
}
@ -192,7 +192,7 @@ class AddressReference
public function setMunicipalityCode(?string $municipalityCode): self
{
$this->municipalityCode = $municipalityCode;
$this->municipalityCode = (string) $municipalityCode;
return $this;
}
@ -227,21 +227,21 @@ class AddressReference
public function setSource(?string $source): self
{
$this->source = $source;
$this->source = (string) $source;
return $this;
}
public function setStreet(?string $street): self
{
$this->street = $street;
$this->street = (string) $street;
return $this;
}
public function setStreetNumber(?string $streetNumber): self
{
$this->streetNumber = $streetNumber;
$this->streetNumber = (string) $streetNumber;
return $this;
}

View File

@ -580,15 +580,15 @@ export default {
this.entity.selected.city = this.context.edit ? this.entity.address.postcode : {};
this.entity.selected.address = {};
this.entity.selected.address.street = this.context.edit ? this.entity.address.street: null;
this.entity.selected.address.streetNumber = this.context.edit ? this.entity.address.streetNumber: null;
this.entity.selected.address.floor = this.context.edit ? this.entity.address.floor: null;
this.entity.selected.address.corridor = this.context.edit ? this.entity.address.corridor: null;
this.entity.selected.address.steps = this.context.edit ? this.entity.address.steps: null;
this.entity.selected.address.flat = this.context.edit ? this.entity.address.flat: null;
this.entity.selected.address.buildingName = this.context.edit ? this.entity.address.buildingName: null;
this.entity.selected.address.distribution = this.context.edit ? this.entity.address.distribution: null;
this.entity.selected.address.extra = this.context.edit ? this.entity.address.extra: null;
this.entity.selected.address.street = this.context.edit ? this.entity.address.street: '';
this.entity.selected.address.streetNumber = this.context.edit ? this.entity.address.streetNumber: '';
this.entity.selected.address.floor = this.context.edit ? this.entity.address.floor: '';
this.entity.selected.address.corridor = this.context.edit ? this.entity.address.corridor: '';
this.entity.selected.address.steps = this.context.edit ? this.entity.address.steps: '';
this.entity.selected.address.flat = this.context.edit ? this.entity.address.flat: '';
this.entity.selected.address.buildingName = this.context.edit ? this.entity.address.buildingName: '';
this.entity.selected.address.distribution = this.context.edit ? this.entity.address.distribution: '';
this.entity.selected.address.extra = this.context.edit ? this.entity.address.extra: '';
this.entity.selected.writeNew.address = this.context.edit && this.entity.address.addressReference === null && this.entity.address.street.length > 0
this.entity.selected.writeNew.postcode = false // NB: this used to be this.context.edit, but think it was erroneous;

View File

@ -13,15 +13,15 @@
</p>
</div>
<div v-else>
<p v-if="address.text"
<p v-if="'' !== address.text"
class="street">
{{ address.text }}
</p>
<p v-if="address.postcode"
<p v-if="null !== address.postcode"
class="postcode">
{{ address.postcode.code }} {{ address.postcode.name }}
</p>
<p v-if="address.country"
<p v-if="null !== address.country"
class="country">
{{ address.country.name.fr }}
</p>

View File

@ -60,9 +60,6 @@ class AddressRender implements ChillEntityRenderInterface
}
/**
* @param Address addr
* @param mixed $addr
*
* @return string[]
*/
public function renderLines(Address $addr, bool $includeCityLine = true, bool $includeCountry = true): array
@ -98,18 +95,18 @@ class AddressRender implements ChillEntityRenderInterface
}
}
return array_values(array_filter($lines, static fn ($l) => null !== $l));
return array_values(array_filter($lines, static fn ($l) => '' !== (string) $l));
}
public function renderStreetLine(Address $addr): ?string
{
if (null !== $addr->getStreet() && $addr->getStreet() !== '') {
if ('' !== $addr->getStreet()) {
$street = $addr->getStreet();
} else {
$street = '';
}
if (null !== $addr->getStreetNumber() && $addr->getStreetNumber() !== '') {
if ('' !== $addr->getStreetNumber()) {
$streetNumber = $addr->getStreetNumber();
} else {
$streetNumber = '';
@ -146,7 +143,7 @@ class AddressRender implements ChillEntityRenderInterface
private function renderBuildingLine(Address $addr): ?string
{
if (null !== $addr->getBuildingName() && $addr->getBuildingName() !== '') {
if ($addr->getBuildingName() !== '') {
$building = $addr->getBuildingName();
} else {
$building = '';
@ -172,7 +169,7 @@ class AddressRender implements ChillEntityRenderInterface
return $res;
}
private function renderCityLine($addr): string
private function renderCityLine(Address $addr): string
{
if (null !== $addr->getPostcode()) {
$res = strtr('{postcode} {label}', [
@ -180,11 +177,9 @@ class AddressRender implements ChillEntityRenderInterface
'{label}' => $addr->getPostcode()->getName(),
]);
if (null !== $addr->getPostCode()->getCountry()->getCountryCode()) {
if ($addr->getPostCode()->getCountry()->getCountryCode() === 'FR') {
if ($addr->getDistribution()) {
$res = $res . ' ' . $addr->getDistribution();
}
if ($addr->getPostcode()->getCountry()->getCountryCode() === 'FR') {
if ('' !== $addr->getDistribution()) {
$res = $res . ' ' . $addr->getDistribution();
}
}
}
@ -192,35 +187,35 @@ class AddressRender implements ChillEntityRenderInterface
return $res ?? '';
}
private function renderCountryLine($addr): ?string
private function renderCountryLine(Address $addr): ?string
{
return $this->translatableStringHelper->localize(
$addr->getPostCode()->getCountry()->getName()
$addr->getPostcode()->getCountry()->getName()
);
}
private function renderDeliveryLine($addr): ?string
private function renderDeliveryLine(Address $addr): string
{
return $addr->getExtra();
}
private function renderIntraBuildingLine($addr): ?string
private function renderIntraBuildingLine(Address $addr): ?string
{
$arr = [];
if ($addr->getFlat()) {
if ('' !== $addr->getFlat()) {
$arr[] = 'appart ' . $addr->getFlat();
}
if ($addr->getFloor()) {
if ('' !== $addr->getFloor()) {
$arr[] = 'ét ' . $addr->getFloor();
}
if ($addr->getCorridor()) {
if ('' !== $addr->getCorridor()) {
$arr[] = 'coul ' . $addr->getCorridor();
}
if ($addr->getSteps()) {
if ('' !== $addr->getSteps()) {
$arr[] = 'esc ' . $addr->getSteps();
}

View File

@ -99,7 +99,7 @@ final class AddressReferenceBaseImporterTest extends KernelTestCase
'abcc guessed fixed'
);
$this->assertCount('1', $addresses);
$this->assertCount(1, $addresses);
$this->assertEquals('Rue test abccc guessed fixed', $addresses[0]->getStreet());
$this->assertEquals($previousAddressId, $addresses[0]->getId());
}

View File

@ -0,0 +1,109 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20230306145728 extends AbstractMigration
{
public function getDescription(): string
{
return 'fix inconsistencies in chill_main_address table';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_main_address ADD createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
$this->addSql('ALTER TABLE chill_main_address ADD updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
$this->addSql('ALTER TABLE chill_main_address ADD createdBy_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_main_address ADD updatedBy_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER street TYPE TEXT');
$this->addSql('UPDATE chill_main_address SET street=\'\' WHERE street IS NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER street SET DEFAULT \'\'');
$this->addSql('ALTER TABLE chill_main_address ALTER streetnumber TYPE TEXT');
$this->addSql('UPDATE chill_main_address SET streetnumber=\'\' WHERE streetnumber IS NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER streetnumber SET DEFAULT \'\'');
$this->addSql('ALTER TABLE chill_main_address ALTER floor SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address SET floor=\'\' WHERE floor IS NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER floor SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER corridor SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address SET corridor=\'\' WHERE corridor IS NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER corridor SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER steps SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address SET steps=\'\' WHERE steps IS NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER steps SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER buildingname TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address ALTER buildingname SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address SET buildingname=\'\' WHERE buildingname IS NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER buildingname SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER flat SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address SET flat=\'\' WHERE flat IS NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER flat SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER distribution TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address ALTER distribution SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address SET distribution=\'\' WHERE distribution IS NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER distribution SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER extra TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address ALTER extra SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address SET extra=\'\' WHERE extra IS NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER extra SET NOT NULL');
$this->addSql('UPDATE chill_main_address SET confidential=FALSE WHERE confidential IS NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER confidential SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER refstatuslastupdate TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
$this->addSql('COMMENT ON COLUMN chill_main_address.point IS \'(DC2Type:point)\'');
$this->addSql('COMMENT ON COLUMN chill_main_address.createdAt IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_main_address.updatedAt IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('COMMENT ON COLUMN chill_main_address.refStatusLastUpdate IS \'(DC2Type:datetime_immutable)\'');
$this->addSql('ALTER TABLE chill_main_address ADD CONSTRAINT FK_165051F63174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE chill_main_address ADD CONSTRAINT FK_165051F665FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_165051F63174800F ON chill_main_address (createdBy_id)');
$this->addSql('CREATE INDEX IDX_165051F665FF1AEC ON chill_main_address (updatedBy_id)');
$this->addSql('COMMENT ON COLUMN chill_main_address_reference.point IS \'(DC2Type:point)\'');
}
public function down(Schema $schema): void
{
$this->throwIrreversibleMigrationException('down method is not double-checked');
$this->addSql('ALTER TABLE chill_main_address DROP CONSTRAINT FK_165051F63174800F');
$this->addSql('ALTER TABLE chill_main_address DROP CONSTRAINT FK_165051F665FF1AEC');
$this->addSql('DROP INDEX IDX_165051F63174800F');
$this->addSql('DROP INDEX IDX_165051F665FF1AEC');
$this->addSql('ALTER TABLE chill_main_address ADD customs JSONB DEFAULT \'[]\'');
$this->addSql('ALTER TABLE chill_main_address DROP createdAt');
$this->addSql('ALTER TABLE chill_main_address DROP updatedAt');
$this->addSql('ALTER TABLE chill_main_address DROP createdBy_id');
$this->addSql('ALTER TABLE chill_main_address DROP updatedBy_id');
$this->addSql('ALTER TABLE chill_main_address ALTER buildingName TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address ALTER buildingName DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address ALTER buildingName DROP NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER confidential SET DEFAULT false');
$this->addSql('ALTER TABLE chill_main_address ALTER confidential DROP NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER corridor DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address ALTER corridor DROP NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER distribution TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address ALTER distribution DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address ALTER distribution DROP NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER extra TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address ALTER extra DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address ALTER extra DROP NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER flat DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address ALTER flat DROP NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER floor DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address ALTER floor DROP NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER isNoAddress SET DEFAULT false');
$this->addSql('ALTER TABLE chill_main_address ALTER point TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address ALTER refStatusLastUpdate TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
$this->addSql('ALTER TABLE chill_main_address ALTER steps DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address ALTER steps DROP NOT NULL');
$this->addSql('ALTER TABLE chill_main_address ALTER street TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address ALTER street DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address ALTER streetNumber TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address ALTER streetNumber DROP DEFAULT');
$this->addSql('COMMENT ON COLUMN chill_main_address.refstatuslastupdate IS NULL');
}
}

View File

@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20230306151218 extends AbstractMigration
{
public function getDescription(): string
{
return 'fix inconsistencies in chill_main_address_reference table';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_main_address_reference ALTER refid TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER refid SET DEFAULT \'\'');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER street TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER street SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address_reference SET street = \'\' WHERE street IS NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER street SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER streetnumber TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER streetnumber SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address_reference SET streetnumber = \'\' WHERE streetnumber IS NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER streetnumber SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalitycode TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalitycode SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address_reference SET municipalitycode = \'\' WHERE municipalitycode IS NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalitycode SET NOT NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER source TYPE TEXT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER source SET DEFAULT \'\'');
$this->addSql('UPDATE chill_main_address_reference SET source = \'\' WHERE source IS NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER source SET NOT NULL');
}
public function down(Schema $schema): void
{
$this->throwIrreversibleMigrationException('not double-checked');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalityCode TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalityCode DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalityCode DROP NOT NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER refId TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER refId DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER source TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER source DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER source DROP NOT NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER street TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER street DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER street DROP NOT NULL');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER streetNumber TYPE VARCHAR(255)');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER streetNumber DROP DEFAULT');
$this->addSql('ALTER TABLE chill_main_address_reference ALTER streetNumber DROP NOT NULL');
}
}