migrations/Inventory/Version20220901134405_InventoryItem.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations\Inventory;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20220901134405_InventoryItem extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Add inventory item table';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql("CREATE TABLE inventory_item (
  18.             id                              SERIAL PRIMARY KEY,
  19.             warehouse_id                    INTEGER                     NOT NULL REFERENCES public.place (id),
  20.             line_item_id                    INTEGER                     NOT NULL REFERENCES public.purchasing_line_item (id),
  21.             available_quantity              INTEGER                     NOT NULL,
  22.             quarantined_quantity            INTEGER                     NOT NULL,
  23.             booked_quantity                 INTEGER                     NOT NULL,
  24.             unit_price                      DECIMAL(18, 5)              NOT NULL,
  25.             value                           DECIMAL(18, 5)              NOT NULL,
  26.             created_by                      INTEGER                     NOT NULL REFERENCES public.user (id),
  27.             updated_by                      INTEGER                              REFERENCES public.user (id),
  28.             created_at                      TIMESTAMP(0) WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
  29.             updated_at                      TIMESTAMP(0) WITH TIME ZONE,
  30.             deleted_at                      TIMESTAMP(0) WITH TIME ZONE,
  31.             CONSTRAINT inventory_item_warehouse_id_item_id_key UNIQUE (warehouse_id, line_item_id)
  32.         )");
  33.         $this->addSql("CREATE INDEX inventory_item_line_item_id_idx ON inventory_item (line_item_id)");
  34.         $this->addSql("CREATE INDEX inventory_item_warehouse_id_idx ON inventory_item (warehouse_id)");
  35.         $this->addSql("CREATE INDEX inventory_item_created_by_idx ON inventory_item (created_by)");
  36.         $this->addSql("CREATE INDEX inventory_item_updated_by_idx ON inventory_item (updated_by)");
  37.     }
  38.     public function down(Schema $schema): void
  39.     {
  40.         $this->addSql("DROP TABLE IF EXISTS inventory_item");
  41.     }
  42. }