migrations/Fleet/Version20200309170457_FleetDriver.php line 1
<?php
declare(strict_types=1);
namespace DoctrineMigrations\Fleet;
use App\Doctrine\Type\Fleet\OperatingStatus;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200309170457_FleetDriver extends AbstractMigration
{
public function getDescription(): string
{
return 'Add drivers table';
}
public function up(Schema $schema): void
{
$operatingStatusType = OperatingStatus::getName();
$defaultStatus = OperatingStatus::OPERATIONAL->value;
$this->addSql("CREATE TABLE fleet_driver (
id SERIAL PRIMARY KEY,
identifier UUID NOT NULL,
employer_id INTEGER REFERENCES public.company (id),
last_name CHARACTER VARYING NOT NULL,
first_name CHARACTER VARYING,
born_on DATE,
country_of_operation CHARACTER VARYING NOT NULL,
status {$operatingStatusType} NOT NULL DEFAULT '{$defaultStatus}',
created_by INTEGER NOT NULL 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,
CONSTRAINT fleet_driver_identifier_key UNIQUE (identifier)
)");
$this->addSql("COMMENT ON COLUMN fleet_driver.identifier IS '(DC2Type:ulid)'");
$this->addSql("CREATE INDEX fleet_driver_employer_id_idx ON fleet_driver (employer_id)");
$this->addSql("CREATE INDEX fleet_driver_created_by_idx ON fleet_driver (created_by)");
$this->addSql("CREATE INDEX fleet_driver_updated_by_idx ON fleet_driver (updated_by)");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE IF EXISTS fleet_driver");
}
}