migrations/Purchasing/Version20200306133210_PurchasingFlow.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations\Purchasing;
  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 Version20200306133210_PurchasingFlow extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Add purchasing flow table';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql("CREATE TABLE purchasing_flow (
  18.             id                              SERIAL PRIMARY KEY,
  19.             client_id                       INTEGER                     NOT NULL REFERENCES public.company (id),
  20.             contract_id                     INTEGER                              REFERENCES public.contract (id),
  21.             label                           CHARACTER VARYING           NOT NULL,
  22.             created_by                      INTEGER                     NOT NULL REFERENCES public.user (id),
  23.             updated_by                      INTEGER                              REFERENCES public.user (id),
  24.             created_at                      TIMESTAMP(0) WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
  25.             updated_at                      TIMESTAMP(0) WITH TIME ZONE,
  26.             deleted_at                      TIMESTAMP(0) WITH TIME ZONE,
  27.             CONSTRAINT purchasing_flow_client_id_label_key UNIQUE (client_id, label)
  28.         )");
  29.         $this->addSql("CREATE INDEX purchasing_flow_client_id_idx ON purchasing_flow (client_id)");
  30.         $this->addSql("CREATE INDEX purchasing_flow_contract_id_idx ON purchasing_flow (contract_id)");
  31.         $this->addSql("CREATE INDEX purchasing_flow_created_by_idx ON purchasing_flow (created_by)");
  32.         $this->addSql("CREATE INDEX purchasing_flow_updated_by_idx ON purchasing_flow (updated_by)");
  33.     }
  34.     public function down(Schema $schema): void
  35.     {
  36.         $this->addSql("DROP TABLE IF EXISTS purchasing_flow");
  37.     }
  38. }