From 1f2177f2043ed37f584bad39a50202ad93ac278a Mon Sep 17 00:00:00 2001 From: Manuel Meister Date: Tue, 14 Jan 2025 21:45:15 +0100 Subject: [PATCH 1/2] Add checklistPrototypeId to track prototypes of checklists --- .../schema/Version20250114202150.php | 31 +++++++++++++++++++ api/src/Entity/Checklist.php | 9 ++++++ 2 files changed, 40 insertions(+) create mode 100644 api/migrations/schema/Version20250114202150.php diff --git a/api/migrations/schema/Version20250114202150.php b/api/migrations/schema/Version20250114202150.php new file mode 100644 index 0000000000..61dc762156 --- /dev/null +++ b/api/migrations/schema/Version20250114202150.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE checklist ADD checklistPrototypeId VARCHAR(16) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE checklist DROP checklistPrototypeId'); + } +} diff --git a/api/src/Entity/Checklist.php b/api/src/Entity/Checklist.php index 455fe17cdf..14038b16e4 100644 --- a/api/src/Entity/Checklist.php +++ b/api/src/Entity/Checklist.php @@ -115,6 +115,13 @@ class Checklist extends BaseEntity implements BelongsToCampInterface, CopyFromPr #[ORM\Column(type: 'text')] public string $name; + /** + * The id of the checklist that was used as a template for creating this checklist. Internal for now, is + * not published through the API. + */ + #[ORM\Column(type: 'string', length: 16, nullable: true)] + public ?string $checklistPrototypeId = null; + /** * Whether this checklist is a template. */ @@ -168,6 +175,8 @@ public function removeChecklistItem(ChecklistItem $checklistItem): self { public function copyFromPrototype($prototype, $entityMap): void { $entityMap->add($prototype, $this); + $this->checklistPrototypeId = $prototype->getId(); + // copy Checklist base properties $this->name ??= $prototype->name; From 0e248fadcd4f3a1c397537cb14f2a557f88f6228 Mon Sep 17 00:00:00 2001 From: Manuel Meister Date: Tue, 14 Jan 2025 21:49:19 +0100 Subject: [PATCH 2/2] Reformat migration to please cs fixer --- api/migrations/schema/Version20250114202150.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/api/migrations/schema/Version20250114202150.php b/api/migrations/schema/Version20250114202150.php index 61dc762156..b06d9fc9e0 100644 --- a/api/migrations/schema/Version20250114202150.php +++ b/api/migrations/schema/Version20250114202150.php @@ -10,21 +10,17 @@ /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20250114202150 extends AbstractMigration -{ - public function getDescription(): string - { +final class Version20250114202150 extends AbstractMigration { + public function getDescription(): string { return 'Add checklistPrototypeId to checklist'; } - public function up(Schema $schema): void - { + public function up(Schema $schema): void { // this up() migration is auto-generated, please modify it to your needs $this->addSql('ALTER TABLE checklist ADD checklistPrototypeId VARCHAR(16) DEFAULT NULL'); } - public function down(Schema $schema): void - { + public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs $this->addSql('ALTER TABLE checklist DROP checklistPrototypeId'); }