From d04edff3dff4850a7b5536b6a015c1d2def37c38 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Tue, 21 May 2024 10:03:56 +0200 Subject: [PATCH] Add changes for elastic --- api/migrations/Version20240516090339.php | 33 ++++++++++++++ api/src/Entity/Application.php | 2 +- api/src/Entity/Database.php | 56 ++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 api/migrations/Version20240516090339.php diff --git a/api/migrations/Version20240516090339.php b/api/migrations/Version20240516090339.php new file mode 100644 index 000000000..ce6cd5fe9 --- /dev/null +++ b/api/migrations/Version20240516090339.php @@ -0,0 +1,33 @@ +addSql('ALTER TABLE database ADD type VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE database ADD auth VARCHAR(255) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE database DROP type'); + $this->addSql('ALTER TABLE database DROP auth'); + } +} diff --git a/api/src/Entity/Application.php b/api/src/Entity/Application.php index 0012e5f27..61613ff68 100644 --- a/api/src/Entity/Application.php +++ b/api/src/Entity/Application.php @@ -263,7 +263,7 @@ class Application private array $certificates = []; /** - * @var array Allowed CORS origins for this application. + * @var array|null Allowed CORS origins for this application. * * @Groups({"read", "write"}) * diff --git a/api/src/Entity/Database.php b/api/src/Entity/Database.php index 1a2bbf60a..eecfbb982 100644 --- a/api/src/Entity/Database.php +++ b/api/src/Entity/Database.php @@ -147,6 +147,26 @@ class Database */ private string $uri; + /** + * @var string The type of database, choose from mongodb and elasticsearch + * + * @Assert\NotNull + * @Assert\Choice({"mongodb", "elasticsearch"}) + * @Groups({"read","write"}) + * + * @ORM\Column(type="string", length=255, nullable=true) + */ + private ?string $type = 'mongodb'; + + /** + * @var string Auth parameter that cannot be stored in the URL, like the API key for ElasticSearch + * + * @Groups({"write"}) + * + * @ORM\Column(type="string", length=255, nullable=true) + */ + private ?string $auth = null; + /** * The organizations that use this Database. * @@ -365,4 +385,40 @@ public function setDateModified(DateTimeInterface $dateModified): self return $this; } + + /** + * @return string|null + */ + public function getAuth(): ?string + { + return $this->auth; + } + + /** + * @param string|null $auth + */ + public function setAuth(?string $auth): self + { + $this->auth = $auth; + + return $this; + } + + /** + * @return string|null + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType(string $type = 'mongodb'): self + { + $this->type = $type; + + return $this; + } }