<?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 Version20250128083104 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE document_template (id UUID NOT NULL, attachment_id UUID DEFAULT NULL, created_by UUID DEFAULT NULL, updated_by UUID DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, code VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_18A1EEDA464E68B ON document_template (attachment_id)');
$this->addSql('CREATE INDEX IDX_18A1EEDADE12AB56 ON document_template (created_by)');
$this->addSql('CREATE INDEX IDX_18A1EEDA16FE72E1 ON document_template (updated_by)');
$this->addSql('COMMENT ON COLUMN document_template.id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN document_template.attachment_id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN document_template.created_by IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN document_template.updated_by IS \'(DC2Type:uuid)\'');
$this->addSql('CREATE TABLE document_template_attachment (id UUID NOT NULL, document_template_id UUID DEFAULT NULL, attachment_id UUID DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_824E180F877338D2 ON document_template_attachment (document_template_id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_824E180F464E68B ON document_template_attachment (attachment_id)');
$this->addSql('COMMENT ON COLUMN document_template_attachment.id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN document_template_attachment.document_template_id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN document_template_attachment.attachment_id IS \'(DC2Type:uuid)\'');
$this->addSql('CREATE TABLE template_attachment (id UUID NOT NULL, file_path VARCHAR(255) DEFAULT NULL, original_name VARCHAR(255) DEFAULT NULL, custom_name VARCHAR(255) DEFAULT NULL, file_size INT DEFAULT NULL, file_type VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN template_attachment.id IS \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE document_template ADD CONSTRAINT FK_18A1EEDA464E68B FOREIGN KEY (attachment_id) REFERENCES document_template_attachment (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE document_template ADD CONSTRAINT FK_18A1EEDADE12AB56 FOREIGN KEY (created_by) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE document_template ADD CONSTRAINT FK_18A1EEDA16FE72E1 FOREIGN KEY (updated_by) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE document_template_attachment ADD CONSTRAINT FK_824E180F877338D2 FOREIGN KEY (document_template_id) REFERENCES document_template (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE document_template_attachment ADD CONSTRAINT FK_824E180F464E68B FOREIGN KEY (attachment_id) REFERENCES template_attachment (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE document_template DROP CONSTRAINT FK_18A1EEDA464E68B');
$this->addSql('ALTER TABLE document_template DROP CONSTRAINT FK_18A1EEDADE12AB56');
$this->addSql('ALTER TABLE document_template DROP CONSTRAINT FK_18A1EEDA16FE72E1');
$this->addSql('ALTER TABLE document_template_attachment DROP CONSTRAINT FK_824E180F877338D2');
$this->addSql('ALTER TABLE document_template_attachment DROP CONSTRAINT FK_824E180F464E68B');
$this->addSql('DROP TABLE document_template');
$this->addSql('DROP TABLE document_template_attachment');
$this->addSql('DROP TABLE template_attachment');
}
}