migrations/Expediting/Version20200309150058_ExpeditingShipment.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations\Expediting;
  4. use App\Doctrine\Type\Expediting\ExpeditingStatus;
  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 Version20200309150058_ExpeditingShipment extends AbstractMigration
  11. {
  12.     public function getDescription(): string
  13.     {
  14.         return 'Add shipment table';
  15.     }
  16.     public function up(Schema $schema): void
  17.     {
  18.         $expeditingStatusType ExpeditingStatus::getName();
  19.         $defaultStatus ExpeditingStatus::PLANNED->value;
  20.         $this->addSql("CREATE TABLE expediting_shipment (
  21.             id                              SERIAL PRIMARY KEY,
  22.             slug                            CHARACTER VARYING             NOT NULL,
  23.             reference                       CHARACTER VARYING             NOT NULL,
  24.             status                          {$expeditingStatusType}       NOT NULL DEFAULT '{$defaultStatus}',
  25.             created_by                      INTEGER                       NOT NULL REFERENCES public.user (id),
  26.             updated_by                      INTEGER                                REFERENCES public.user (id),
  27.             created_at                      TIMESTAMP(0) WITH TIME ZONE   NOT NULL DEFAULT CURRENT_TIMESTAMP,
  28.             updated_at                      TIMESTAMP(0) WITH TIME ZONE,
  29.             deleted_at                      TIMESTAMP(0) WITH TIME ZONE,
  30.             CONSTRAINT expediting_shipment_slug_key UNIQUE (slug),
  31.             CONSTRAINT expediting_shipment_reference_key UNIQUE (reference)
  32.         )");
  33.         $this->addSql("CREATE INDEX expediting_shipment_created_by_idx ON expediting_shipment (created_by)");
  34.         $this->addSql("CREATE INDEX expediting_shipment_updated_by_idx ON expediting_shipment (updated_by)");
  35.     }
  36.     public function down(Schema $schema): void
  37.     {
  38.         $this->addSql("DROP TABLE IF EXISTS expediting_shipment");
  39.     }
  40. }