<?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 Version20211226104458 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql("CREATE SCHEMA reminders;");
$this->addSql("
CREATE TABLE reminders.handlers (
id SERIAL,
code VARCHAR(64) NOT NULL,
locale VARCHAR(16) NOT NULL,
controller VARCHAR(255) NOT NULL,
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("
CREATE TRIGGER tgr_reminders_handlers__main_table_history
BEFORE INSERT OR UPDATE
ON reminders.handlers
FOR EACH ROW EXECUTE PROCEDURE main_table_history();
");
$this->addSql("
CREATE TABLE reminders.logs (
id SERIAL,
handler_id integer,
object_id integer,
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 reminders.logs
ADD CONSTRAINT fk_reminders_logs__handler_id
FOREIGN KEY (handler_id)
REFERENCES reminders.handlers(id)
ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED;
");
$this->addSql("
CREATE TRIGGER tgr_reminders_logs__main_table_history
BEFORE INSERT OR UPDATE
ON reminders.logs
FOR EACH ROW EXECUTE PROCEDURE main_table_history();
");
}
public function down(Schema $schema): void
{
$this->addSql("DROP TABLE reminders.handlers");
$this->addSql("DROP TABLE reminders.logs");
}
}