migrations/Version20211217192914.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  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 Version20211217192914 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         $this->addSql("
  18.         CREATE TABLE intervention_requests.reclaims (
  19.             id SERIAL,
  20.             message TEXT NOT NULL,
  21.             done_by_id INT DEFAULT NULL,
  22.             intervention_request_id INT DEFAULT NULL,
  23.             status SMALLINT DEFAULT 0,
  24.             created_at timestamp(0) without time zone DEFAULT NOW()::timestamp without time zone,
  25.             updated_at timestamp(0) without time zone DEFAULT NULL::timestamp without time zone,
  26.             deleted_at timestamp(0) without time zone DEFAULT NULL::timestamp without time zone,
  27.             created_by integer,
  28.             updated_by integer,
  29.             deleted_by integer,
  30.             enabled smallint DEFAULT 1 NOT NULL,
  31.             deleted smallint DEFAULT 0 NOT NULL,
  32.             PRIMARY KEY(id)
  33.         )
  34.        ");
  35.         $this->addSql("
  36.         ALTER TABLE ONLY intervention_requests.reclaims
  37.             ADD CONSTRAINT fk_reclaims__done_by_id
  38.             FOREIGN KEY (done_by_id)
  39.             REFERENCES public.users(id)
  40.             ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
  41.         ");
  42.         $this->addSql("
  43.         ALTER TABLE ONLY intervention_requests.reclaims
  44.             ADD CONSTRAINT fk_reclaims__intervention_request_id
  45.             FOREIGN KEY (intervention_request_id)
  46.             REFERENCES public.intervention_requests(id)
  47.             ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
  48.         ");
  49.         $this->addSql("
  50.         CREATE TRIGGER tgr_reclaims__main_table_history
  51.             BEFORE INSERT OR UPDATE
  52.             ON intervention_requests.reclaims
  53.             FOR EACH ROW EXECUTE PROCEDURE main_table_history();
  54.         
  55.         ");
  56.     }
  57.     public function down(Schema $schema): void
  58.     {
  59.         $this->addSql("DROP TABLE intervention_requests.reclaims");
  60.     }
  61. }