migrations/Delete/Version20241210130543_InventoryWithdrawal.php line 1

  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations\Delete;
  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 Version20241210130543_InventoryWithdrawal extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'Add inventory withdrawal table';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql('CREATE TABLE inventory_x_withdrawal (
  18.             id                              SERIAL PRIMARY KEY,
  19.             slug                            CHARACTER VARYING NOT NULL,
  20.             reference                       CHARACTER VARYING NOT NULL,
  21.             type                            CHARACTER VARYING,
  22.             consumer                        CHARACTER VARYING,
  23.             reason                          CHARACTER VARYING,
  24.             
  25.             requested_for                   TIMESTAMP(0) WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
  26.             accepted_at                     TIMESTAMP(0) WITH TIME ZONE,
  27.             processed_at                    TIMESTAMP(0) WITH TIME ZONE,
  28.             picked_at                       TIMESTAMP(0) WITH TIME ZONE,
  29.             rejected_at                     TIMESTAMP(0) WITH TIME ZONE,
  30.             
  31.             created_by                      INTEGER                              REFERENCES public.user (id),
  32.             updated_by                      INTEGER                              REFERENCES public.user (id),
  33.             created_at                      TIMESTAMP(0) WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
  34.             updated_at                      TIMESTAMP(0) WITH TIME ZONE,
  35.             deleted_at                      TIMESTAMP(0) WITH TIME ZONE,
  36.             
  37.             CONSTRAINT inventory_x_withdrawal_slug_key UNIQUE (slug),
  38.             CONSTRAINT inventory_x_withdrawal_reference_key UNIQUE (reference)
  39.         )');
  40.         $this->addSql("CREATE INDEX inventory_x_withdrawal_created_by_idx ON inventory_x_withdrawal (created_by)");
  41.         $this->addSql("CREATE INDEX inventory_x_withdrawal_updated_by_idx ON inventory_x_withdrawal (updated_by)");
  42.     }
  43.     public function down(Schema $schema): void
  44.     {
  45.         $this->addSql('DROP TABLE IF EXISTS inventory_x_withdrawal');
  46.     }
  47. }