migrations/Expediting/Version20200309095920_ExpeditingRepacking.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations\Expediting;
  4. use App\Doctrine\Type\Expediting\RepackingMotivation;
  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 Version20200309095920_ExpeditingRepacking extends AbstractMigration
  11. {
  12.     public function getDescription(): string
  13.     {
  14.         return 'Add repacking table';
  15.     }
  16.     public function up(Schema $schema): void
  17.     {
  18.         $repackingMotivationType RepackingMotivation::getName();
  19.         $this->addSql("CREATE TABLE expediting_repacking (
  20.             id                              SERIAL PRIMARY KEY,
  21.             identifier                      UUID                        NOT NULL,
  22.             completed_at                    TIMESTAMP(0) WITH TIME ZONE NOT NULL,
  23.             motivation                      {$repackingMotivationType}  NOT NULL,
  24.             created_by                      INTEGER                     NOT NULL REFERENCES public.user (id),
  25.             updated_by                      INTEGER                              REFERENCES public.user (id),
  26.             created_at                      TIMESTAMP(0) WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
  27.             updated_at                      TIMESTAMP(0) WITH TIME ZONE,
  28.             deleted_at                      TIMESTAMP(0) WITH TIME ZONE,
  29.             CONSTRAINT expediting_repacking_identifier_key UNIQUE (identifier)
  30.         )");
  31.         $this->addSql("COMMENT ON COLUMN expediting_repacking.identifier IS '(DC2Type:ulid)'");
  32.         $this->addSql("CREATE INDEX expediting_repacking_created_by_idx ON expediting_repacking (created_by)");
  33.         $this->addSql("CREATE INDEX expediting_repacking_updated_by_idx ON expediting_repacking (updated_by)");
  34.     }
  35.     public function down(Schema $schema): void
  36.     {
  37.         $this->addSql("DROP TABLE IF EXISTS expediting_repacking");
  38.     }
  39. }