<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190828113314 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add time entry table';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE TABLE time_entry (
id UUID NOT NULL,
user_id UUID DEFAULT NULL,
project_id UUID DEFAULT NULL,
timer_start TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL,
timer_end TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL,
description TEXT DEFAULT NULL,
PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_6E537C0CA76ED395 ON time_entry (user_id)');
$this->addSql('CREATE INDEX IDX_6E537C0C166D1F9C ON time_entry (project_id)');
$this->addSql('COMMENT ON COLUMN time_entry.id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN time_entry.user_id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN time_entry.project_id IS \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE time_entry ADD CONSTRAINT FK_6E537C0CA76ED395 FOREIGN KEY (user_id) REFERENCES hub_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE time_entry ADD CONSTRAINT FK_6E537C0C166D1F9C FOREIGN KEY (project_id) REFERENCES project (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('DROP TABLE time_entry');
}
}