add time to field date, prepare and run migration script

This commit is contained in:
Tchama 2019-01-10 15:31:40 +01:00
parent d123e4137f
commit 7b8f2d1206
2 changed files with 30 additions and 1 deletions

View File

@ -12,7 +12,7 @@ Chill\EventBundle\Entity\Event:
type: string
length: '150'
date:
type: date
type: datetime
oneToMany:
participations:
targetEntity: Chill\EventBundle\Entity\Participation

View File

@ -0,0 +1,29 @@
<?php declare(strict_types=1);
namespace Application\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Switch event date to datetime
*/
final class Version20190110140538 extends AbstractMigration
{
public function up(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 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');
}
}