remove timezone from calendar and calendar range

This commit is contained in:
Julien Fastré 2022-06-06 17:49:51 +02:00
parent dab9204ec7
commit dc22d18e6a
4 changed files with 91 additions and 4 deletions

View File

@ -102,7 +102,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
private CommentEmbeddable $comment; private CommentEmbeddable $comment;
/** /**
* @ORM\Column(type="datetimetz_immutable") * @ORM\Column(type="datetime_immutable", nullable=false)
* @Serializer\Groups({"calendar:read", "read"}) * @Serializer\Groups({"calendar:read", "read"})
*/ */
private ?DateTimeImmutable $endDate = null; private ?DateTimeImmutable $endDate = null;
@ -169,7 +169,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
private ?bool $sendSMS; private ?bool $sendSMS;
/** /**
* @ORM\Column(type="datetimetz_immutable") * @ORM\Column(type="datetime_immutable", nullable=false)
* @Serializer\Groups({"calendar:read", "read"}) * @Serializer\Groups({"calendar:read", "read"})
*/ */
private ?DateTimeImmutable $startDate = null; private ?DateTimeImmutable $startDate = null;
@ -550,6 +550,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
public function setStartDate(DateTimeImmutable $startDate): self public function setStartDate(DateTimeImmutable $startDate): self
{ {
dump('startDate', $startDate);
$this->startDate = $startDate; $this->startDate = $startDate;
return $this; return $this;

View File

@ -38,7 +38,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
private ?Calendar $calendar = null; private ?Calendar $calendar = null;
/** /**
* @ORM\Column(type="datetimetz_immutable") * @ORM\Column(type="datetime_immutable", nullable=false)
* @groups({"read", "write", "calendar:read"}) * @groups({"read", "write", "calendar:read"})
*/ */
private ?DateTimeImmutable $endDate = null; private ?DateTimeImmutable $endDate = null;
@ -52,7 +52,7 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
private $id; private $id;
/** /**
* @ORM\Column(type="datetimetz_immutable") * @ORM\Column(type="datetime_immutable", nullable=false)
* @groups({"read", "write", "calendar:read"}) * @groups({"read", "write", "calendar:read"})
*/ */
private ?DateTimeImmutable $startDate = null; private ?DateTimeImmutable $startDate = null;

View File

@ -0,0 +1,43 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\Migrations\Calendar;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20220606153851 extends AbstractMigration
{
public function down(Schema $schema): void
{
$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('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)\'');
}
}

View File

@ -0,0 +1,43 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\Migrations\Calendar;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20220606154119 extends AbstractMigration
{
public function down(Schema $schema): void
{
$this->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)\'');
}
}