migrations/Expediting/Version20200309150058_ExpeditingShipment.php line 1
<?php
declare(strict_types=1);
namespace DoctrineMigrations\Expediting;
use App\Doctrine\Type\Expediting\ExpeditingStatus;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200309150058_ExpeditingShipment extends AbstractMigration
{
public function getDescription(): string
{
return 'Add shipment table';
}
public function up(Schema $schema): void
{
$expeditingStatusType = ExpeditingStatus::getName();
$defaultStatus = ExpeditingStatus::PLANNED->value;
$this->addSql("CREATE TABLE expediting_shipment (
id SERIAL PRIMARY KEY,
slug CHARACTER VARYING NOT NULL,
reference CHARACTER VARYING NOT NULL,
status {$expeditingStatusType} 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 expediting_shipment_slug_key UNIQUE (slug),
CONSTRAINT expediting_shipment_reference_key UNIQUE (reference)
)");
$this->addSql("CREATE INDEX expediting_shipment_created_by_idx ON expediting_shipment (created_by)");
$this->addSql("CREATE INDEX expediting_shipment_updated_by_idx ON expediting_shipment (updated_by)");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE IF EXISTS expediting_shipment");
}
}