migrations/Delete/Version20241210131920_InventoryMovement.php line 1
<?php
declare(strict_types=1);
namespace DoctrineMigrations\Delete;
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 Version20241210131920_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_x_movement (
id SERIAL PRIMARY KEY,
batch_id INTEGER REFERENCES public.expediting_z_batch (id),
withdrawal_id INTEGER REFERENCES public.inventory_x_withdrawal (id),
material_id INTEGER NOT NULL REFERENCES public.inventory_x_material (id),
quantity INTEGER NOT NULL,
unit_price DECIMAL(18, 5) NOT NULL,
value DECIMAL(18, 5) NOT NULL,
type {$movementType} NOT NULL,
completed_at TIMESTAMP(0) WITH TIME ZONE NOT NULL,
created_by INTEGER 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
)");
$this->addSql("CREATE INDEX inventory_x_movement_batch_id_idx ON inventory_x_movement (batch_id)");
$this->addSql("CREATE INDEX inventory_x_movement_withdrawal_id_idx ON inventory_x_movement (withdrawal_id)");
$this->addSql("CREATE INDEX inventory_x_movement_material_id_idx ON inventory_x_movement (material_id)");
$this->addSql("CREATE INDEX inventory_x_movement_created_by_idx ON inventory_x_movement (created_by)");
$this->addSql("CREATE INDEX inventory_x_movement_updated_by_idx ON inventory_x_movement (updated_by)");
}
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE IF EXISTS inventory_x_movement');
}
}