migrations/Inventory/Version20220901132630_InventoryMovement.php line 1
<?php
declare(strict_types=1);
namespace DoctrineMigrations\Inventory;
use App\Doctrine\Type\Inventory\MovementType;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220901132630_InventoryMovement extends AbstractMigration
{
public function getDescription(): string
{
return 'Add inventory movement table';
}
public function up(Schema $schema): void
{
$movementType = MovementType::getName();
$this->addSql("CREATE TABLE inventory_package_movement (
id SERIAL PRIMARY KEY,
identifier UUID NOT NULL,
warehouse_id INTEGER NOT NULL REFERENCES public.place (id),
package_id INTEGER NOT NULL REFERENCES public.expediting_package (id),
shipping_segment_id INTEGER REFERENCES public.expediting_shipping_segment (id),
repacking_id INTEGER REFERENCES public.expediting_repacking (id),
exit_id INTEGER REFERENCES public.inventory_package_movement (id),
type {$movementType} 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_package_movement_identifier_key UNIQUE (identifier),
CONSTRAINT inventory_package_movement_xor_movement CHECK (
(shipping_segment_id IS NOT NULL AND repacking_id IS NULL) OR
(shipping_segment_id IS NULL AND repacking_id IS NOT NULL)
)
)");
$this->addSql("COMMENT ON COLUMN inventory_package_movement.identifier IS '(DC2Type:ulid)'");
$this->addSql("CREATE INDEX inventory_package_movement_warehouse_id_idx ON inventory_package_movement (warehouse_id)");
$this->addSql("CREATE INDEX inventory_package_movement_package_id_idx ON inventory_package_movement (package_id)");
$this->addSql("CREATE INDEX inventory_package_movement_shipping_segment_id_idx ON inventory_package_movement (shipping_segment_id)");
$this->addSql("CREATE INDEX inventory_package_movement_repacking_id_idx ON inventory_package_movement (repacking_id)");
$this->addSql("CREATE INDEX inventory_package_movement_exit_id_idx ON inventory_package_movement (exit_id)");
$this->addSql("CREATE INDEX inventory_package_movement_created_by_idx ON inventory_package_movement (created_by)");
$this->addSql("CREATE INDEX inventory_package_movement_updated_by_idx ON inventory_package_movement (updated_by)");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE IF EXISTS inventory_package_movement");
}
}