From 82cb359072023ac41b734efbb517a49bebb00637 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 19 Sep 2024 14:37:57 +0200 Subject: [PATCH] Clean migration for main bundle --- src/Bundle/ChillMainBundle/Entity/Center.php | 2 +- src/Bundle/ChillMainBundle/Entity/Country.php | 2 +- .../Entity/CronJobExecution.php | 2 +- .../Entity/DashboardConfigItem.php | 2 +- .../ChillMainBundle/Entity/Location.php | 2 +- .../ChillMainBundle/Entity/LocationType.php | 4 +-- .../ChillMainBundle/Entity/Notification.php | 2 +- .../Entity/PermissionsGroup.php | 2 +- src/Bundle/ChillMainBundle/Entity/User.php | 2 +- .../migrations/Version20240918150339.php | 32 +++++++++++++++++++ 10 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/migrations/Version20240918150339.php diff --git a/src/Bundle/ChillMainBundle/Entity/Center.php b/src/Bundle/ChillMainBundle/Entity/Center.php index 0d0858a6e..1ac7f5977 100644 --- a/src/Bundle/ChillMainBundle/Entity/Center.php +++ b/src/Bundle/ChillMainBundle/Entity/Center.php @@ -36,7 +36,7 @@ class Center implements HasCenterInterface, \Stringable #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)] private string $name = ''; - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => true])] private bool $isActive = true; /** diff --git a/src/Bundle/ChillMainBundle/Entity/Country.php b/src/Bundle/ChillMainBundle/Entity/Country.php index 533caeaec..c5433d46c 100644 --- a/src/Bundle/ChillMainBundle/Entity/Country.php +++ b/src/Bundle/ChillMainBundle/Entity/Country.php @@ -39,7 +39,7 @@ class Country * @var array */ #[Groups(['read', 'docgen:read'])] - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '[]', 'jsonb' => true])] #[Context(['is-translatable' => true], groups: ['docgen:read'])] private array $name = []; diff --git a/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php b/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php index f2f1194c8..dd3c5da58 100644 --- a/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php +++ b/src/Bundle/ChillMainBundle/Entity/CronJobExecution.php @@ -30,7 +30,7 @@ class CronJobExecution #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: true, options: ['default' => null])] private ?int $lastStatus = null; - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => "'{}'::jsonb", 'jsonb' => true])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '{}', 'jsonb' => true])] private array $lastExecutionData = []; public function __construct( diff --git a/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php b/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php index 6fdd34cfc..d94e93742 100644 --- a/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php +++ b/src/Bundle/ChillMainBundle/Entity/DashboardConfigItem.php @@ -39,7 +39,7 @@ class DashboardConfigItem private ?User $user = null; #[Serializer\Groups(['dashboardConfigItem:read'])] - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '[]', 'jsonb' => true])] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '{}', 'jsonb' => true])] private array $metadata = []; public function getId(): ?int diff --git a/src/Bundle/ChillMainBundle/Entity/Location.php b/src/Bundle/ChillMainBundle/Entity/Location.php index 228fd089f..5705e6a1a 100644 --- a/src/Bundle/ChillMainBundle/Entity/Location.php +++ b/src/Bundle/ChillMainBundle/Entity/Location.php @@ -26,7 +26,7 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap; class Location implements TrackCreationInterface, TrackUpdateInterface { #[Serializer\Groups(['read'])] - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: true)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => true])] private bool $active = true; #[Serializer\Groups(['read', 'write', 'docgen:read'])] diff --git a/src/Bundle/ChillMainBundle/Entity/LocationType.php b/src/Bundle/ChillMainBundle/Entity/LocationType.php index df212646a..16bca82e9 100644 --- a/src/Bundle/ChillMainBundle/Entity/LocationType.php +++ b/src/Bundle/ChillMainBundle/Entity/LocationType.php @@ -34,7 +34,7 @@ class LocationType final public const STATUS_REQUIRED = 'required'; #[Serializer\Groups(['read'])] - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: true)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => true])] private bool $active = true; #[Serializer\Groups(['read'])] @@ -54,7 +54,7 @@ class LocationType private ?string $defaultFor = null; #[Serializer\Groups(['read'])] - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, options: ['default' => true])] private bool $editableByUsers = true; #[Serializer\Groups(['read', 'docgen:read'])] diff --git a/src/Bundle/ChillMainBundle/Entity/Notification.php b/src/Bundle/ChillMainBundle/Entity/Notification.php index d85a144b0..9f08e0487 100644 --- a/src/Bundle/ChillMainBundle/Entity/Notification.php +++ b/src/Bundle/ChillMainBundle/Entity/Notification.php @@ -41,7 +41,7 @@ class Notification implements TrackUpdateInterface * * @var array|string[] */ - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '[]', 'jsonb' => true])] private array $addressesEmails = []; /** diff --git a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php index 4902fca95..723513c8b 100644 --- a/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php +++ b/src/Bundle/ChillMainBundle/Entity/PermissionsGroup.php @@ -24,7 +24,7 @@ class PermissionsGroup /** * @var string[] */ - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '[]', 'jsonb' => true])] private array $flags = []; /** diff --git a/src/Bundle/ChillMainBundle/Entity/User.php b/src/Bundle/ChillMainBundle/Entity/User.php index 448efbdd1..8a31779f9 100644 --- a/src/Bundle/ChillMainBundle/Entity/User.php +++ b/src/Bundle/ChillMainBundle/Entity/User.php @@ -45,7 +45,7 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter /** * Array where SAML attributes's data are stored. */ - #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false)] + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, nullable: false, options: ['default' => '[]', 'jsonb' => true])] private array $attributes = []; #[ORM\ManyToOne(targetEntity: Civility::class)] diff --git a/src/Bundle/ChillMainBundle/migrations/Version20240918150339.php b/src/Bundle/ChillMainBundle/migrations/Version20240918150339.php new file mode 100644 index 000000000..d0a4f858b --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20240918150339.php @@ -0,0 +1,32 @@ +addSql('ALTER TABLE chill_main_address DROP customs'); + $this->addSql('ALTER TABLE chill_main_dashboard_config_item ALTER metadata SET NOT NULL'); + $this->addSql('ALTER TABLE chill_main_location ALTER active SET NOT NULL'); + $this->addSql('ALTER TABLE chill_main_location_type ALTER active SET NOT NULL'); + $this->addSql('ALTER TABLE chill_main_location_type ALTER editablebyusers SET NOT NULL'); + $this->addSql('ALTER TABLE country ALTER name SET NOT NULL'); + $this->addSql('ALTER TABLE permission_groups ALTER name SET DEFAULT \'\''); + $this->addSql('ALTER TABLE users ALTER attributes SET DEFAULT \'[]\''); + } + + public function down(Schema $schema): void + { + } +}