From 59f70fd98a4cbe42f6b6c1b3078c4a466993c43a Mon Sep 17 00:00:00 2001 From: Oscar Ellis Date: Thu, 15 Jan 2026 20:08:50 +0000 Subject: [PATCH 1/4] add nullable to abbreviation --- migrations/Version20260115200506.php | 26 ++++++++++++++++++++++++++ src/Perscom/Entity/Specialty.php | 8 ++++---- 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 migrations/Version20260115200506.php diff --git a/migrations/Version20260115200506.php b/migrations/Version20260115200506.php new file mode 100644 index 0000000..e6b694c --- /dev/null +++ b/migrations/Version20260115200506.php @@ -0,0 +1,26 @@ +addSql('ALTER TABLE perscom_specialty CHANGE abbreviation abbreviation VARCHAR(8) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE perscom_specialty CHANGE abbreviation abbreviation VARCHAR(8) NOT NULL'); + } +} diff --git a/src/Perscom/Entity/Specialty.php b/src/Perscom/Entity/Specialty.php index 3ad1b7c..977b450 100644 --- a/src/Perscom/Entity/Specialty.php +++ b/src/Perscom/Entity/Specialty.php @@ -31,9 +31,9 @@ class Specialty implements PerscomEntityInterface, SortableEntityInterface #[ORM\Column(type: 'text')] private string $description = ''; - #[ORM\Column(length: 8)] + #[ORM\Column(length: 8, nullable: true)] #[Assert\Length(max: 8)] - private string $abbreviation = ''; + private ?string $abbreviation = null; public static function getPerscomResource(Perscom $perscom): Batchable|Crudable { @@ -60,12 +60,12 @@ public function setDescription(string $description): void $this->description = $description; } - public function getAbbreviation(): string + public function getAbbreviation(): ?string { return $this->abbreviation; } - public function setAbbreviation(string $abbreviation): void + public function setAbbreviation(?string $abbreviation): void { $this->abbreviation = $abbreviation; } From 62d062ba8f6ea65750b6a20120af165f10e1662a Mon Sep 17 00:00:00 2001 From: Oscar Ellis Date: Thu, 15 Jan 2026 20:34:44 +0000 Subject: [PATCH 2/4] makes abbreviation not nullable --- ...rsion20260115200506.php => Version20260115203053.php} | 8 ++++---- src/Admin/Form/SpecialtyType.php | 1 - src/Perscom/Entity/Specialty.php | 9 +++++---- 3 files changed, 9 insertions(+), 9 deletions(-) rename migrations/{Version20260115200506.php => Version20260115203053.php} (83%) diff --git a/migrations/Version20260115200506.php b/migrations/Version20260115203053.php similarity index 83% rename from migrations/Version20260115200506.php rename to migrations/Version20260115203053.php index e6b694c..2d97882 100644 --- a/migrations/Version20260115200506.php +++ b/migrations/Version20260115203053.php @@ -7,20 +7,20 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; -final class Version20260115200506 extends AbstractMigration +final class Version20260115203053 extends AbstractMigration { public function getDescription(): string { - return 'makes abbreviation nullable'; + return 'makes abbreviation not nullable'; } public function up(Schema $schema): void { - $this->addSql('ALTER TABLE perscom_specialty CHANGE abbreviation abbreviation VARCHAR(8) DEFAULT NULL'); + $this->addSql('ALTER TABLE perscom_specialty CHANGE abbreviation abbreviation VARCHAR(8) NOT NULL'); } public function down(Schema $schema): void { - $this->addSql('ALTER TABLE perscom_specialty CHANGE abbreviation abbreviation VARCHAR(8) NOT NULL'); + $this->addSql('ALTER TABLE perscom_specialty CHANGE abbreviation abbreviation VARCHAR(8) DEFAULT NULL'); } } diff --git a/src/Admin/Form/SpecialtyType.php b/src/Admin/Form/SpecialtyType.php index 8b24847..abb56be 100644 --- a/src/Admin/Form/SpecialtyType.php +++ b/src/Admin/Form/SpecialtyType.php @@ -29,7 +29,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]) ->add('abbreviation', TextType::class, [ 'help' => 'Give this specialty an abbreviation. For example the specialty of a US Infantryman would get the abbreviation of 11B.', - 'required' => false, ]) ; } diff --git a/src/Perscom/Entity/Specialty.php b/src/Perscom/Entity/Specialty.php index 977b450..dc20132 100644 --- a/src/Perscom/Entity/Specialty.php +++ b/src/Perscom/Entity/Specialty.php @@ -31,9 +31,10 @@ class Specialty implements PerscomEntityInterface, SortableEntityInterface #[ORM\Column(type: 'text')] private string $description = ''; - #[ORM\Column(length: 8, nullable: true)] + #[ORM\Column(length: 8)] #[Assert\Length(max: 8)] - private ?string $abbreviation = null; + #[Assert\NotBlank(allowNull: false)] + private string $abbreviation; public static function getPerscomResource(Perscom $perscom): Batchable|Crudable { @@ -60,12 +61,12 @@ public function setDescription(string $description): void $this->description = $description; } - public function getAbbreviation(): ?string + public function getAbbreviation(): string { return $this->abbreviation; } - public function setAbbreviation(?string $abbreviation): void + public function setAbbreviation(string $abbreviation): void { $this->abbreviation = $abbreviation; } From 18a84fde1fab5a7372e6d16465459913172163eb Mon Sep 17 00:00:00 2001 From: Oscar Ellis Date: Thu, 15 Jan 2026 20:40:07 +0000 Subject: [PATCH 3/4] deleted migration --- migrations/Version20260115203053.php | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 migrations/Version20260115203053.php diff --git a/migrations/Version20260115203053.php b/migrations/Version20260115203053.php deleted file mode 100644 index 2d97882..0000000 --- a/migrations/Version20260115203053.php +++ /dev/null @@ -1,26 +0,0 @@ -addSql('ALTER TABLE perscom_specialty CHANGE abbreviation abbreviation VARCHAR(8) NOT NULL'); - } - - public function down(Schema $schema): void - { - $this->addSql('ALTER TABLE perscom_specialty CHANGE abbreviation abbreviation VARCHAR(8) DEFAULT NULL'); - } -} From 5d7fbc68d29d8060bf50dd3ff9c6e1ba2a0aac97 Mon Sep 17 00:00:00 2001 From: JannesD Date: Thu, 15 Jan 2026 21:41:54 +0100 Subject: [PATCH 4/4] Update src/Perscom/Entity/Specialty.php --- src/Perscom/Entity/Specialty.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Perscom/Entity/Specialty.php b/src/Perscom/Entity/Specialty.php index dc20132..d88252b 100644 --- a/src/Perscom/Entity/Specialty.php +++ b/src/Perscom/Entity/Specialty.php @@ -34,7 +34,7 @@ class Specialty implements PerscomEntityInterface, SortableEntityInterface #[ORM\Column(length: 8)] #[Assert\Length(max: 8)] #[Assert\NotBlank(allowNull: false)] - private string $abbreviation; + private string $abbreviation = ''; public static function getPerscomResource(Perscom $perscom): Batchable|Crudable {