From a709b3afb60255ec36aca890d4101e0465e71f6e Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 22 Apr 2021 12:25:34 +0200 Subject: [PATCH] add addressReference in Chill Main + migration --- .../Entity/AddressReference.php | 147 ++++++++++++++++++ .../Repository/AddressReferenceRepository.php | 50 ++++++ .../migrations/Version20210422101743.php | 33 ++++ 3 files changed, 230 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/Entity/AddressReference.php create mode 100644 src/Bundle/ChillMainBundle/Repository/AddressReferenceRepository.php create mode 100644 src/Bundle/ChillMainBundle/migrations/Version20210422101743.php diff --git a/src/Bundle/ChillMainBundle/Entity/AddressReference.php b/src/Bundle/ChillMainBundle/Entity/AddressReference.php new file mode 100644 index 000000000..8f1678425 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Entity/AddressReference.php @@ -0,0 +1,147 @@ +id; + } + + public function getRefId(): ?string + { + return $this->refId; + } + + public function setRefId(string $refId): self + { + $this->refId = $refId; + + return $this; + } + + public function getStreet(): ?string + { + return $this->street; + } + + public function setStreet(?string $street): self + { + $this->street = $street; + + return $this; + } + + public function getStreetNumber(): ?string + { + return $this->streetNumber; + } + + public function setStreetNumber(?string $streetNumber): self + { + $this->streetNumber = $streetNumber; + + return $this; + } + + public function getPostcode(): ?string + { + return $this->postcode; + } + + public function setPostcode(?string $postcode): self + { + $this->postcode = $postcode; + + return $this; + } + + public function getMunicipalityCode(): ?string + { + return $this->municipalityCode; + } + + public function setMunicipalityCode(?string $municipalityCode): self + { + $this->municipalityCode = $municipalityCode; + + return $this; + } + + public function getSource(): ?string + { + return $this->source; + } + + public function setSource(?string $source): self + { + $this->source = $source; + + return $this; + } + + public function getPoint(): ?string + { + return $this->point; + } + + public function setPoint(string $point): self + { + $this->point = $point; + + return $this; + } +} diff --git a/src/Bundle/ChillMainBundle/Repository/AddressReferenceRepository.php b/src/Bundle/ChillMainBundle/Repository/AddressReferenceRepository.php new file mode 100644 index 000000000..208151420 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Repository/AddressReferenceRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('a') + ->andWhere('a.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('a.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?AddressReference + { + return $this->createQueryBuilder('a') + ->andWhere('a.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Bundle/ChillMainBundle/migrations/Version20210422101743.php b/src/Bundle/ChillMainBundle/migrations/Version20210422101743.php new file mode 100644 index 000000000..2d4341155 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20210422101743.php @@ -0,0 +1,33 @@ +addSql('CREATE SEQUENCE chill_main_address_reference_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_main_address_reference (id INT NOT NULL, postcode_id INT DEFAULT NULL, refId VARCHAR(255) NOT NULL, street VARCHAR(255) DEFAULT NULL, streetNumber VARCHAR(255) DEFAULT NULL, municipalityCode VARCHAR(255) DEFAULT NULL, source VARCHAR(255) DEFAULT NULL, point VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_CA6C1BD7EECBFDF1 ON chill_main_address_reference (postcode_id)'); + $this->addSql('ALTER TABLE chill_main_address_reference ADD CONSTRAINT FK_CA6C1BD7EECBFDF1 FOREIGN KEY (postcode_id) REFERENCES chill_main_postal_code (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema) : void + { + $this->addSql('DROP SEQUENCE chill_main_address_reference_id_seq CASCADE'); + $this->addSql('DROP TABLE chill_main_address_reference'); + } +}