From dc22d18e6a335057d9b447ff724740ce512ea604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 6 Jun 2022 17:49:51 +0200 Subject: [PATCH] remove timezone from calendar and calendar range --- .../ChillCalendarBundle/Entity/Calendar.php | 5 ++- .../Entity/CalendarRange.php | 4 +- .../migrations/Version20220606153851.php | 43 +++++++++++++++++++ .../migrations/Version20220606154119.php | 43 +++++++++++++++++++ 4 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 src/Bundle/ChillCalendarBundle/migrations/Version20220606153851.php create mode 100644 src/Bundle/ChillCalendarBundle/migrations/Version20220606154119.php diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 99b0d6cc7..6d0a476cb 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -102,7 +102,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface private CommentEmbeddable $comment; /** - * @ORM\Column(type="datetimetz_immutable") + * @ORM\Column(type="datetime_immutable", nullable=false) * @Serializer\Groups({"calendar:read", "read"}) */ private ?DateTimeImmutable $endDate = null; @@ -169,7 +169,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface private ?bool $sendSMS; /** - * @ORM\Column(type="datetimetz_immutable") + * @ORM\Column(type="datetime_immutable", nullable=false) * @Serializer\Groups({"calendar:read", "read"}) */ private ?DateTimeImmutable $startDate = null; @@ -550,6 +550,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface public function setStartDate(DateTimeImmutable $startDate): self { + dump('startDate', $startDate); $this->startDate = $startDate; return $this; diff --git a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php index 088842876..78846cd83 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php +++ b/src/Bundle/ChillCalendarBundle/Entity/CalendarRange.php @@ -38,7 +38,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface private ?Calendar $calendar = null; /** - * @ORM\Column(type="datetimetz_immutable") + * @ORM\Column(type="datetime_immutable", nullable=false) * @groups({"read", "write", "calendar:read"}) */ private ?DateTimeImmutable $endDate = null; @@ -52,7 +52,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface private $id; /** - * @ORM\Column(type="datetimetz_immutable") + * @ORM\Column(type="datetime_immutable", nullable=false) * @groups({"read", "write", "calendar:read"}) */ private ?DateTimeImmutable $startDate = null; diff --git a/src/Bundle/ChillCalendarBundle/migrations/Version20220606153851.php b/src/Bundle/ChillCalendarBundle/migrations/Version20220606153851.php new file mode 100644 index 000000000..1ae43eb41 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/migrations/Version20220606153851.php @@ -0,0 +1,43 @@ +addSql('ALTER TABLE chill_calendar.calendar ALTER endDate TYPE TIMESTAMP(0) WITH TIME ZONE'); + $this->addSql('ALTER TABLE chill_calendar.calendar ALTER endDate DROP DEFAULT'); + $this->addSql('ALTER TABLE chill_calendar.calendar ALTER startDate TYPE TIMESTAMP(0) WITH TIME ZONE'); + $this->addSql('ALTER TABLE chill_calendar.calendar ALTER startDate DROP DEFAULT'); + $this->addSql('COMMENT ON COLUMN chill_calendar.calendar.enddate IS \'(DC2Type:datetimetz_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_calendar.calendar.startdate IS \'(DC2Type:datetimetz_immutable)\''); + } + + public function getDescription(): string + { + return 'remove timezone from dates in calendar entity'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_calendar.calendar ALTER startdate TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE chill_calendar.calendar ALTER startdate DROP DEFAULT'); + $this->addSql('ALTER TABLE chill_calendar.calendar ALTER enddate TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE chill_calendar.calendar ALTER enddate DROP DEFAULT'); + $this->addSql('COMMENT ON COLUMN chill_calendar.calendar.startDate IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_calendar.calendar.endDate IS \'(DC2Type:datetime_immutable)\''); + } +} diff --git a/src/Bundle/ChillCalendarBundle/migrations/Version20220606154119.php b/src/Bundle/ChillCalendarBundle/migrations/Version20220606154119.php new file mode 100644 index 000000000..990e5bcab --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/migrations/Version20220606154119.php @@ -0,0 +1,43 @@ +addSql('ALTER TABLE chill_calendar.calendar_range ALTER endDate TYPE TIMESTAMP(0) WITH TIME ZONE'); + $this->addSql('ALTER TABLE chill_calendar.calendar_range ALTER endDate DROP DEFAULT'); + $this->addSql('ALTER TABLE chill_calendar.calendar_range ALTER startDate TYPE TIMESTAMP(0) WITH TIME ZONE'); + $this->addSql('ALTER TABLE chill_calendar.calendar_range ALTER startDate DROP DEFAULT'); + $this->addSql('COMMENT ON COLUMN chill_calendar.calendar_range.enddate IS \'(DC2Type:datetimetz_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_calendar.calendar_range.startdate IS \'(DC2Type:datetimetz_immutable)\''); + } + + public function getDescription(): string + { + return 'remove timezone from calendar range'; + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_calendar.calendar_range ALTER startdate TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE chill_calendar.calendar_range ALTER startdate DROP DEFAULT'); + $this->addSql('ALTER TABLE chill_calendar.calendar_range ALTER enddate TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE chill_calendar.calendar_range ALTER enddate DROP DEFAULT'); + $this->addSql('COMMENT ON COLUMN chill_calendar.calendar_range.startDate IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_calendar.calendar_range.endDate IS \'(DC2Type:datetime_immutable)\''); + } +}