From 51e9b1fcf20474923a8bf0ec1ffd451f499121e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 19 Apr 2021 13:24:15 +0200 Subject: [PATCH] AccompanyingPeriod/Origin: set label as json --- .../Entity/AccompanyingPeriod/Origin.php | 2 +- .../migrations/Version20210419105940.php | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20210419105940.php diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php index 4016cd833..42c75efca 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Origin.php @@ -39,7 +39,7 @@ class Origin private $id; /** - * @ORM\Column(type="string", length=255) + * @ORM\Column(type="json") */ private $label; diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20210419105940.php b/src/Bundle/ChillPersonBundle/migrations/Version20210419105940.php new file mode 100644 index 000000000..4214c7069 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20210419105940.php @@ -0,0 +1,36 @@ +addSql('ALTER TABLE chill_person_accompanying_period_origin ' + . 'ALTER label TYPE JSON USING json_build_object(\'fr\', label)::jsonb'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_origin ' + . 'ALTER label DROP DEFAULT'); + } + + public function down(Schema $schema) : void + { + // this will keep the '"' at first and last character, but is acceptable + $this->addSql('ALTER TABLE chill_person_accompanying_period_origin ' + . 'ALTER label TYPE VARCHAR(255) USING label->\'fr\'::text'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_origin ' + . 'ALTER label DROP DEFAULT'); + } +}