migrations/Inventory/Version20220901134405_InventoryItem.php line 1
<?php
declare(strict_types=1);
namespace DoctrineMigrations\Inventory;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220901134405_InventoryItem extends AbstractMigration
{
public function getDescription(): string
{
return 'Add inventory item table';
}
public function up(Schema $schema): void
{
$this->addSql("CREATE TABLE inventory_item (
id SERIAL PRIMARY KEY,
warehouse_id INTEGER NOT NULL REFERENCES public.place (id),
line_item_id INTEGER NOT NULL REFERENCES public.purchasing_line_item (id),
available_quantity INTEGER NOT NULL,
quarantined_quantity INTEGER NOT NULL,
booked_quantity INTEGER NOT NULL,
unit_price DECIMAL(18, 5) NOT NULL,
value DECIMAL(18, 5) 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_warehouse_id_item_id_key UNIQUE (warehouse_id, line_item_id)
)");
$this->addSql("CREATE INDEX inventory_item_line_item_id_idx ON inventory_item (line_item_id)");
$this->addSql("CREATE INDEX inventory_item_warehouse_id_idx ON inventory_item (warehouse_id)");
$this->addSql("CREATE INDEX inventory_item_created_by_idx ON inventory_item (created_by)");
$this->addSql("CREATE INDEX inventory_item_updated_by_idx ON inventory_item (updated_by)");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE IF EXISTS inventory_item");
}
}