From 31912b9b911fe96ad62b3c7ed1ef050f9ca492fe Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 4 Nov 2024 14:43:38 +0100 Subject: [PATCH] Clean migration of NULL definition on entity properties --- .../Entity/CustomFieldsGroup.php | 2 +- .../migrations/Version20241104085341.php | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillMainBundle/migrations/Version20241104085341.php diff --git a/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldsGroup.php b/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldsGroup.php index 723b47612..265dd972b 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldsGroup.php +++ b/src/Bundle/ChillCustomFieldsBundle/Entity/CustomFieldsGroup.php @@ -49,7 +49,7 @@ class CustomFieldsGroup #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] private array|string $name; - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: true)] private array $options = []; /** diff --git a/src/Bundle/ChillMainBundle/migrations/Version20241104085341.php b/src/Bundle/ChillMainBundle/migrations/Version20241104085341.php new file mode 100644 index 000000000..90b58e1ba --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20241104085341.php @@ -0,0 +1,53 @@ +addSql('ALTER TABLE activity ALTER privatecomment_comments SET NOT NULL'); + $this->addSql('ALTER TABLE activityreason ALTER name SET NOT NULL'); + $this->addSql('ALTER TABLE activityreasoncategory ALTER name SET NOT NULL'); + $this->addSql('ALTER TABLE chill_main_dashboard_config_item ALTER metadata SET NOT NULL'); + $this->addSql('ALTER TABLE chill_main_location_type ALTER editablebyusers SET NOT NULL'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_work ALTER privatecomment_comments SET NOT NULL'); + $this->addSql('ALTER TABLE chill_person_phone ALTER phonenumber SET NOT NULL'); + $this->addSql('ALTER TABLE chill_person_relationships ALTER createdby_id DROP NOT NULL'); + $this->addSql('ALTER TABLE chill_person_relationships ALTER createdat DROP NOT NULL'); + $this->addSql('ALTER TABLE chill_person_resource ALTER createdby_id DROP NOT NULL'); + $this->addSql('ALTER TABLE chill_person_resource ALTER createdat DROP NOT NULL'); + $this->addSql('ALTER TABLE country ALTER name SET NOT NULL'); + $this->addSql('ALTER TABLE customfield ALTER required SET NOT NULL'); + $this->addSql('ALTER TABLE chill_3party.third_party ALTER firstname SET NOT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_person_accompanying_period_work ALTER privateComment_comments DROP NOT NULL'); + $this->addSql('ALTER TABLE chill_person_phone ALTER phonenumber DROP NOT NULL'); + $this->addSql('ALTER TABLE chill_main_location_type ALTER editableByUsers DROP NOT NULL'); + $this->addSql('ALTER TABLE chill_main_dashboard_config_item ALTER metadata DROP NOT NULL'); + $this->addSql('ALTER TABLE chill_3party.third_party ALTER firstname DROP NOT NULL'); + $this->addSql('ALTER TABLE country ALTER name DROP NOT NULL'); + $this->addSql('ALTER TABLE chill_person_household_composition_type ALTER label DROP NOT NULL'); + $this->addSql('ALTER TABLE customfieldsgroup ALTER options DROP NOT NULL'); + $this->addSql('ALTER TABLE activity ALTER privateComment_comments DROP NOT NULL'); + $this->addSql('ALTER TABLE chill_person_resource ALTER createdAt SET NOT NULL'); + $this->addSql('ALTER TABLE chill_person_resource ALTER createdBy_id SET NOT NULL'); + $this->addSql('ALTER TABLE activityreasoncategory ALTER name DROP NOT NULL'); + $this->addSql('ALTER TABLE activityreason ALTER name DROP NOT NULL'); + $this->addSql('ALTER TABLE customfield ALTER required DROP NOT NULL'); + $this->addSql('ALTER TABLE chill_person_relations ALTER isActive SET NOT NULL'); + } +}