From 7b8f2d120626af6e38e5586df08c2c0525ab0370 Mon Sep 17 00:00:00 2001 From: Tchama Date: Thu, 10 Jan 2019 15:31:40 +0100 Subject: [PATCH] add time to field date, prepare and run migration script --- Resources/config/doctrine/Event.orm.yml | 2 +- .../migrations/Version20190110140538.php | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 Resources/migrations/Version20190110140538.php diff --git a/Resources/config/doctrine/Event.orm.yml b/Resources/config/doctrine/Event.orm.yml index eb02041e4..3d7e0ec5a 100644 --- a/Resources/config/doctrine/Event.orm.yml +++ b/Resources/config/doctrine/Event.orm.yml @@ -12,7 +12,7 @@ Chill\EventBundle\Entity\Event: type: string length: '150' date: - type: date + type: datetime oneToMany: participations: targetEntity: Chill\EventBundle\Entity\Participation diff --git a/Resources/migrations/Version20190110140538.php b/Resources/migrations/Version20190110140538.php new file mode 100644 index 000000000..545f58f58 --- /dev/null +++ b/Resources/migrations/Version20190110140538.php @@ -0,0 +1,29 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_event_event ALTER date TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE chill_event_event ALTER date DROP DEFAULT'); + + } + + public function down(Schema $schema) : void + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE chill_event_event ALTER date TYPE DATE'); + $this->addSql('ALTER TABLE chill_event_event ALTER date DROP DEFAULT'); + } +}