<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20211217192914 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql("
CREATE TABLE intervention_requests.reclaims (
id SERIAL,
message TEXT NOT NULL,
done_by_id INT DEFAULT NULL,
intervention_request_id INT DEFAULT NULL,
status SMALLINT DEFAULT 0,
created_at timestamp(0) without time zone DEFAULT NOW()::timestamp without time zone,
updated_at timestamp(0) without time zone DEFAULT NULL::timestamp without time zone,
deleted_at timestamp(0) without time zone DEFAULT NULL::timestamp without time zone,
created_by integer,
updated_by integer,
deleted_by integer,
enabled smallint DEFAULT 1 NOT NULL,
deleted smallint DEFAULT 0 NOT NULL,
PRIMARY KEY(id)
)
");
$this->addSql("
ALTER TABLE ONLY intervention_requests.reclaims
ADD CONSTRAINT fk_reclaims__done_by_id
FOREIGN KEY (done_by_id)
REFERENCES public.users(id)
ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
");
$this->addSql("
ALTER TABLE ONLY intervention_requests.reclaims
ADD CONSTRAINT fk_reclaims__intervention_request_id
FOREIGN KEY (intervention_request_id)
REFERENCES public.intervention_requests(id)
ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
");
$this->addSql("
CREATE TRIGGER tgr_reclaims__main_table_history
BEFORE INSERT OR UPDATE
ON intervention_requests.reclaims
FOR EACH ROW EXECUTE PROCEDURE main_table_history();
");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE intervention_requests.reclaims");
}
}