migrations/Scheduler/Version20200320140918_Task.php line 1
<?php
declare(strict_types=1);
namespace DoctrineMigrations\Scheduler;
use App\Doctrine\Type\Scheduler\TaskStatus;
use App\Doctrine\Type\Scheduler\TaskType;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200320140918_Task extends AbstractMigration
{
public function getDescription(): string
{
return 'Add task table';
}
public function up(Schema $schema): void
{
$this->addSql(TaskType::getRegistrationSQL());
$this->addSql(TaskStatus::getRegistrationSQL());
$taskTypeType = TaskType::getName();
$taskStatusType = TaskStatus::getName();
$defaultStatus = TaskStatus::PLANNED->value;
$this->addSql("CREATE TABLE task (
id SERIAL PRIMARY KEY,
assignee_id INTEGER REFERENCES public.user (id),
type {$taskTypeType} NOT NULL,
status {$taskStatusType} NOT NULL DEFAULT '{$defaultStatus}',
is_progressive BOOLEAN NOT NULL DEFAULT FALSE,
is_action BOOLEAN NOT NULL DEFAULT FALSE,
delayed BOOLEAN NOT NULL DEFAULT FALSE,
urgent BOOLEAN NOT NULL DEFAULT FALSE,
description CHARACTER VARYING NOT NULL,
entity CHARACTER VARYING NOT NULL,
entity_id INTEGER NOT NULL,
planned_for TIMESTAMP(0) WITH TIME ZONE NOT NULL,
started_on TIMESTAMP(0) WITH TIME ZONE,
completed_on TIMESTAMP(0) WITH TIME ZONE,
created_by INTEGER REFERENCES public.user (id),
updated_by INTEGER REFERENCES public.user (id),
created_at TIMESTAMP(0) WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP(0) WITH TIME ZONE,
deleted_at TIMESTAMP(0) WITH TIME ZONE
)");
$this->addSql("CREATE INDEX task_assignee_id_idx ON task (assignee_id)");
$this->addSql("CREATE INDEX task_created_by_idx ON task (created_by)");
$this->addSql("CREATE INDEX task_updated_by_idx ON task (updated_by)");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE IF EXISTS task");
$this->addSql(TaskStatus::getDeletionSQL());
$this->addSql(TaskType::getDeletionSQL());
}
}