From 9d0589d455848dd968dae866623af27588a57f7a Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 23 Jul 2021 16:25:05 +0200 Subject: [PATCH] rdv: use datetime instead of date fields --- .../ChillCalendarBundle/Entity/Calendar.php | 4 +- .../Resources/views/Calendar/show.html.twig | 4 +- .../migrations/Version20210723142003.php | 39 +++++++++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 src/Bundle/ChillCalendarBundle/migrations/Version20210723142003.php diff --git a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php index 618b354b7..3ee5bcc54 100644 --- a/src/Bundle/ChillCalendarBundle/Entity/Calendar.php +++ b/src/Bundle/ChillCalendarBundle/Entity/Calendar.php @@ -91,12 +91,12 @@ class Calendar private CommentEmbeddable $comment; /** - * @ORM\Column(type="date_immutable") + * @ORM\Column(type="datetimetz_immutable") */ private \DateTimeImmutable $startDate; /** - * @ORM\Column(type="date_immutable") + * @ORM\Column(type="datetimetz_immutable") */ private \DateTimeImmutable $endDate; diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig index 2674573dc..f6df7ccdf 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/show.html.twig @@ -12,10 +12,10 @@

{{ 'Calendar data'|trans }}

{{ 'start date'|trans }}
-
{{ entity.startDate|format_date('long') }}
+
{{ entity.startDate|format_datetime('long') }}
{{ 'end date'|trans }}
-
{{ entity.endDate|format_date('long') }}
+
{{ entity.endDate|format_datetime('long') }}
{{ 'cancel reason'|trans }}
diff --git a/src/Bundle/ChillCalendarBundle/migrations/Version20210723142003.php b/src/Bundle/ChillCalendarBundle/migrations/Version20210723142003.php new file mode 100644 index 000000000..0af4fb1b8 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/migrations/Version20210723142003.php @@ -0,0 +1,39 @@ +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('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('COMMENT ON COLUMN chill_calendar.calendar.startDate IS \'(DC2Type:datetimetz_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_calendar.calendar.endDate IS \'(DC2Type:datetimetz_immutable)\''); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_calendar.calendar ALTER startDate TYPE DATE'); + $this->addSql('ALTER TABLE chill_calendar.calendar ALTER startDate DROP DEFAULT'); + $this->addSql('ALTER TABLE chill_calendar.calendar ALTER endDate TYPE DATE'); + $this->addSql('ALTER TABLE chill_calendar.calendar ALTER endDate DROP DEFAULT'); + $this->addSql('COMMENT ON COLUMN chill_calendar.calendar.startdate IS \'(DC2Type:date_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_calendar.calendar.enddate IS \'(DC2Type:date_immutable)\''); + } +}