migrations/Version20250128083104.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 Version20250128083104 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $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))');
  19.         $this->addSql('CREATE UNIQUE INDEX UNIQ_18A1EEDA464E68B ON document_template (attachment_id)');
  20.         $this->addSql('CREATE INDEX IDX_18A1EEDADE12AB56 ON document_template (created_by)');
  21.         $this->addSql('CREATE INDEX IDX_18A1EEDA16FE72E1 ON document_template (updated_by)');
  22.         $this->addSql('COMMENT ON COLUMN document_template.id IS \'(DC2Type:uuid)\'');
  23.         $this->addSql('COMMENT ON COLUMN document_template.attachment_id IS \'(DC2Type:uuid)\'');
  24.         $this->addSql('COMMENT ON COLUMN document_template.created_by IS \'(DC2Type:uuid)\'');
  25.         $this->addSql('COMMENT ON COLUMN document_template.updated_by IS \'(DC2Type:uuid)\'');
  26.         $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))');
  27.         $this->addSql('CREATE UNIQUE INDEX UNIQ_824E180F877338D2 ON document_template_attachment (document_template_id)');
  28.         $this->addSql('CREATE UNIQUE INDEX UNIQ_824E180F464E68B ON document_template_attachment (attachment_id)');
  29.         $this->addSql('COMMENT ON COLUMN document_template_attachment.id IS \'(DC2Type:uuid)\'');
  30.         $this->addSql('COMMENT ON COLUMN document_template_attachment.document_template_id IS \'(DC2Type:uuid)\'');
  31.         $this->addSql('COMMENT ON COLUMN document_template_attachment.attachment_id IS \'(DC2Type:uuid)\'');
  32.         $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))');
  33.         $this->addSql('COMMENT ON COLUMN template_attachment.id IS \'(DC2Type:uuid)\'');
  34.         $this->addSql('ALTER TABLE document_template ADD CONSTRAINT FK_18A1EEDA464E68B FOREIGN KEY (attachment_id) REFERENCES document_template_attachment (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  35.         $this->addSql('ALTER TABLE document_template ADD CONSTRAINT FK_18A1EEDADE12AB56 FOREIGN KEY (created_by) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  36.         $this->addSql('ALTER TABLE document_template ADD CONSTRAINT FK_18A1EEDA16FE72E1 FOREIGN KEY (updated_by) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  37.         $this->addSql('ALTER TABLE document_template_attachment ADD CONSTRAINT FK_824E180F877338D2 FOREIGN KEY (document_template_id) REFERENCES document_template (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  38.         $this->addSql('ALTER TABLE document_template_attachment ADD CONSTRAINT FK_824E180F464E68B FOREIGN KEY (attachment_id) REFERENCES template_attachment (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  39.     }
  40.     public function down(Schema $schema): void
  41.     {
  42.         // this down() migration is auto-generated, please modify it to your needs
  43.         $this->addSql('CREATE SCHEMA public');
  44.         $this->addSql('ALTER TABLE document_template DROP CONSTRAINT FK_18A1EEDA464E68B');
  45.         $this->addSql('ALTER TABLE document_template DROP CONSTRAINT FK_18A1EEDADE12AB56');
  46.         $this->addSql('ALTER TABLE document_template DROP CONSTRAINT FK_18A1EEDA16FE72E1');
  47.         $this->addSql('ALTER TABLE document_template_attachment DROP CONSTRAINT FK_824E180F877338D2');
  48.         $this->addSql('ALTER TABLE document_template_attachment DROP CONSTRAINT FK_824E180F464E68B');
  49.         $this->addSql('DROP TABLE document_template');
  50.         $this->addSql('DROP TABLE document_template_attachment');
  51.         $this->addSql('DROP TABLE template_attachment');
  52.     }
  53. }