From 40eb1ca7a8eba43234523a93dfa2ced1f5894229 Mon Sep 17 00:00:00 2001 From: myrmidex Date: Thu, 4 Jun 2026 19:46:16 +0000 Subject: [PATCH] Move to Api/ --- migrations/Version20260604194453.php | 34 +++++++++++++++++++ src/Entity/Rating.php | 20 +++++------ .../{ => Api}/SubjectControllerTest.php | 2 +- 3 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 migrations/Version20260604194453.php rename tests/Unit/Controller/{ => Api}/SubjectControllerTest.php (98%) diff --git a/migrations/Version20260604194453.php b/migrations/Version20260604194453.php new file mode 100644 index 0000000..a71becb --- /dev/null +++ b/migrations/Version20260604194453.php @@ -0,0 +1,34 @@ +addSql('CREATE TABLE rating (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, score SMALLINT DEFAULT NULL, subject_id INT NOT NULL, PRIMARY KEY (id))'); + $this->addSql('CREATE INDEX IDX_D889262223EDC87 ON rating (subject_id)'); + $this->addSql('ALTER TABLE rating ADD CONSTRAINT FK_D889262223EDC87 FOREIGN KEY (subject_id) REFERENCES subject (id) NOT DEFERRABLE'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE rating DROP CONSTRAINT FK_D889262223EDC87'); + $this->addSql('DROP TABLE rating'); + } +} diff --git a/src/Entity/Rating.php b/src/Entity/Rating.php index c4642fa..be7e3c9 100644 --- a/src/Entity/Rating.php +++ b/src/Entity/Rating.php @@ -16,36 +16,36 @@ class Rating #[ORM\ManyToOne(inversedBy: 'ratings')] #[ORM\JoinColumn(nullable: false)] - private ?Subject $subject_id = null; + private ?Subject $subject = null; #[ORM\Column(type: Types::SMALLINT, nullable: true)] - private ?int $rating = null; + private ?int $score = null; public function getId(): ?int { return $this->id; } - public function getSubjectId(): ?Subject + public function getSubject(): ?Subject { - return $this->subject_id; + return $this->subject; } - public function setSubjectId(?Subject $subject_id): static + public function setSubject(?Subject $subject): static { - $this->subject_id = $subject_id; + $this->subject = $subject; return $this; } - public function getRating(): ?int + public function getScore(): ?int { - return $this->rating; + return $this->score; } - public function setRating(?int $rating): static + public function setScore(?int $score): static { - $this->rating = $rating; + $this->score = $score; return $this; } diff --git a/tests/Unit/Controller/SubjectControllerTest.php b/tests/Unit/Controller/Api/SubjectControllerTest.php similarity index 98% rename from tests/Unit/Controller/SubjectControllerTest.php rename to tests/Unit/Controller/Api/SubjectControllerTest.php index af8748e..3105b33 100644 --- a/tests/Unit/Controller/SubjectControllerTest.php +++ b/tests/Unit/Controller/Api/SubjectControllerTest.php @@ -1,6 +1,6 @@