migrations/Inventory/Version20220902094516_InventoryItemDisposal.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations\Inventory;
  4. use App\Doctrine\Type\Inventory\DisposalReason;
  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 Version20220902094516_InventoryItemDisposal extends AbstractMigration
  11. {
  12.     public function getDescription(): string
  13.     {
  14.         return 'Add item disposal table';
  15.     }
  16.     public function up(Schema $schema): void
  17.     {
  18.         $disposalReason DisposalReason::getName();
  19.         $this->addSql("CREATE TABLE inventory_item_disposal (
  20.             id                              SERIAL PRIMARY KEY,
  21.             identifier                      UUID                        NOT NULL,
  22.             cause                           {$disposalReason}           NOT NULL,
  23.             completed_at                    TIMESTAMP(0) WITH TIME ZONE 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 inventory_item_disposal_identifier_key UNIQUE (identifier)
  30.         )");
  31.         $this->addSql("COMMENT ON COLUMN inventory_item_disposal.identifier IS '(DC2Type:ulid)'");
  32.         $this->addSql("CREATE INDEX inventory_item_disposal_created_by_idx ON inventory_item_disposal (created_by)");
  33.         $this->addSql("CREATE INDEX inventory_item_disposal_updated_by_idx ON inventory_item_disposal (updated_by)");
  34.     }
  35.     public function down(Schema $schema): void
  36.     {
  37.         $this->addSql("DROP TABLE IF EXISTS inventory_item_disposal");
  38.     }
  39. }