migrations/Expediting/Version20200310112638_ExpeditingContainer.php line 1
<?php
declare(strict_types=1);
namespace DoctrineMigrations\Expediting;
use App\Doctrine\Type\Expediting\ContainerSize;
use App\Doctrine\Type\Expediting\ContainerType;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200310112638_ExpeditingContainer extends AbstractMigration
{
public function getDescription(): string
{
return 'Add container table';
}
public function up(Schema $schema): void
{
$containerTypeType = ContainerType::getName();
$containerSizeType = ContainerSize::getName();
$this->addSql("CREATE TABLE expediting_container (
id SERIAL PRIMARY KEY,
identifier UUID NOT NULL,
shipment_id INTEGER REFERENCES public.expediting_shipment (id),
seal_number CHARACTER VARYING,
identification_number CHARACTER VARYING,
container_type {$containerTypeType} NOT NULL,
container_size {$containerSizeType} NOT NULL,
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_container_identifier_key UNIQUE (identifier),
CONSTRAINT expediting_container_seal_number_key UNIQUE (seal_number)
)");
$this->addSql("COMMENT ON COLUMN expediting_container.identifier IS '(DC2Type:ulid)'");
$this->addSql("CREATE INDEX expediting_container_shipment_id_idx ON expediting_container (shipment_id)");
$this->addSql("CREATE INDEX expediting_container_created_by_idx ON expediting_container (created_by)");
$this->addSql("CREATE INDEX expediting_container_updated_by_idx ON expediting_container (updated_by)");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE IF EXISTS expediting_container");
}
}