migrations/Delete/Version20241210131920_InventoryMovement.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations\Delete;
  4. use App\Doctrine\Type\Inventory\MovementType;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\Migrations\AbstractMigration;
  7. /**
  8.  * Auto-generated Migration: Please modify to your needs!
  9.  */
  10. final class Version20241210131920_InventoryMovement extends AbstractMigration
  11. {
  12.     public function getDescription(): string
  13.     {
  14.         return 'Add inventory movement table';
  15.     }
  16.     public function up(Schema $schema): void
  17.     {
  18.         $movementType MovementType::getName();
  19.         $this->addSql("CREATE TABLE inventory_x_movement (
  20.             id                              SERIAL PRIMARY KEY,
  21.             batch_id                        INTEGER                              REFERENCES public.expediting_z_batch (id),
  22.             withdrawal_id                   INTEGER                              REFERENCES public.inventory_x_withdrawal (id),
  23.             material_id                     INTEGER                     NOT NULL REFERENCES public.inventory_x_material (id),
  24.             quantity                        INTEGER                     NOT NULL,
  25.             unit_price                      DECIMAL(18, 5)              NOT NULL,
  26.             value                           DECIMAL(18, 5)              NOT NULL,
  27.             type                            {$movementType}             NOT NULL,
  28.             completed_at                    TIMESTAMP(0) WITH TIME ZONE NOT NULL,
  29.             created_by                      INTEGER                              REFERENCES public.user (id),
  30.             updated_by                      INTEGER                              REFERENCES public.user (id),
  31.             created_at                      TIMESTAMP(0) WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
  32.             updated_at                      TIMESTAMP(0) WITH TIME ZONE,
  33.             deleted_at                      TIMESTAMP(0) WITH TIME ZONE
  34.         )");
  35.         $this->addSql("CREATE INDEX inventory_x_movement_batch_id_idx ON inventory_x_movement (batch_id)");
  36.         $this->addSql("CREATE INDEX inventory_x_movement_withdrawal_id_idx ON inventory_x_movement (withdrawal_id)");
  37.         $this->addSql("CREATE INDEX inventory_x_movement_material_id_idx ON inventory_x_movement (material_id)");
  38.         $this->addSql("CREATE INDEX inventory_x_movement_created_by_idx ON inventory_x_movement (created_by)");
  39.         $this->addSql("CREATE INDEX inventory_x_movement_updated_by_idx ON inventory_x_movement (updated_by)");
  40.     }
  41.     public function down(Schema $schema): void
  42.     {
  43.         $this->addSql('DROP TABLE IF EXISTS inventory_x_movement');
  44.     }
  45. }