migrations/Fleet/Version20200309171219_FleetVehicle.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 Version20200309171219_FleetVehicle extends AbstractMigration
{
public function getDescription(): string
{
return 'Add vehicle table';
}
public function up(Schema $schema): void
{
$operatingStatusType = OperatingStatus::getName();
$defaultStatus = OperatingStatus::OPERATIONAL->value;
$this->addSql("CREATE TABLE fleet_vehicle (
id SERIAL PRIMARY KEY,
identifier UUID NOT NULL,
owner_id INTEGER REFERENCES public.company (id),
make CHARACTER VARYING,
model CHARACTER VARYING,
front_number CHARACTER VARYING NOT NULL,
rear_number CHARACTER VARYING NOT NULL,
registered_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_vehicle_identifier_key UNIQUE (identifier)
)");
$this->addSql("COMMENT ON COLUMN fleet_vehicle.identifier IS '(DC2Type:ulid)'");
$this->addSql("CREATE INDEX fleet_vehicle_owner_id_idx ON fleet_vehicle (owner_id)");
$this->addSql("CREATE INDEX fleet_vehicle_created_by_idx ON fleet_vehicle (created_by)");
$this->addSql("CREATE INDEX fleet_vehicle_updated_by_idx ON fleet_vehicle (updated_by)");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE IF EXISTS fleet_vehicle");
}
}