migrations/Inventory/Version20220902094516_InventoryItemDisposal.php line 1
<?php
declare(strict_types=1);
namespace DoctrineMigrations\Inventory;
use App\Doctrine\Type\Inventory\DisposalReason;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220902094516_InventoryItemDisposal extends AbstractMigration
{
public function getDescription(): string
{
return 'Add item disposal table';
}
public function up(Schema $schema): void
{
$disposalReason = DisposalReason::getName();
$this->addSql("CREATE TABLE inventory_item_disposal (
id SERIAL PRIMARY KEY,
identifier UUID NOT NULL,
cause {$disposalReason} NOT NULL,
completed_at TIMESTAMP(0) WITH TIME ZONE 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 inventory_item_disposal_identifier_key UNIQUE (identifier)
)");
$this->addSql("COMMENT ON COLUMN inventory_item_disposal.identifier IS '(DC2Type:ulid)'");
$this->addSql("CREATE INDEX inventory_item_disposal_created_by_idx ON inventory_item_disposal (created_by)");
$this->addSql("CREATE INDEX inventory_item_disposal_updated_by_idx ON inventory_item_disposal (updated_by)");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE IF EXISTS inventory_item_disposal");
}
}