migrations/Delete/Version20241011153450_ExpeditingContainer.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations\Delete;
  4. use App\Doctrine\Type\Expediting\ContainerSize;
  5. use App\Doctrine\Type\Expediting\ContainerType;
  6. use Doctrine\DBAL\Schema\Schema;
  7. use Doctrine\Migrations\AbstractMigration;
  8. /**
  9.  * Auto-generated Migration: Please modify to your needs!
  10.  */
  11. final class Version20241011153450_ExpeditingContainer extends AbstractMigration
  12. {
  13.     public function getDescription(): string
  14.     {
  15.         return 'Add expediting container';
  16.     }
  17.     public function up(Schema $schema): void
  18.     {
  19.         $containerTypeType ContainerType::getName();
  20.         $containerSizeType ContainerSize::getName();
  21.         $this->addSql("CREATE TABLE expediting_z_container (
  22.             id                              SERIAL PRIMARY KEY,
  23.             
  24.             batch_id                        INTEGER                                REFERENCES expediting_z_batch (id),
  25.             seal_number                     CHARACTER VARYING,
  26.             identification_number           CHARACTER VARYING,
  27.             container_type                  {$containerTypeType}        NOT NULL,
  28.             container_size                  {$containerSizeType}        NOT NULL,
  29.             tare_weight                     DECIMAL(18, 2),
  30.             gross_weight                    DECIMAL(18, 2),
  31.             volume                          DECIMAL(18, 2),
  32.             created_by                      INTEGER                     NOT NULL REFERENCES public.user (id),
  33.             updated_by                      INTEGER                              REFERENCES public.user (id),
  34.             created_at                      TIMESTAMP(0) WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
  35.             updated_at                      TIMESTAMP(0) WITH TIME ZONE,
  36.             deleted_at                      TIMESTAMP(0) WITH TIME ZONE,
  37.             CONSTRAINT expediting_z_container_seal_number_key UNIQUE (seal_number)
  38.         )");
  39.         $this->addSql("CREATE INDEX expediting_z_container_batch_id_idx ON expediting_z_container (batch_id)");
  40.         $this->addSql("CREATE INDEX expediting_z_container_created_by_idx ON expediting_z_container (created_by)");
  41.         $this->addSql("CREATE INDEX expediting_z_container_updated_by_idx ON expediting_z_container (updated_by)");
  42.     }
  43.     public function down(Schema $schema): void
  44.     {
  45.         $this->addSql("DROP TABLE IF EXISTS expediting_z_container");
  46.     }
  47. }