55 lines
5.0 KiB
PHP
55 lines
5.0 KiB
PHP
|
|
<?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 Version20260331081951 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 sign_document (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, document_id VARCHAR(64) NOT NULL, title VARCHAR(255) NOT NULL, dest_email VARCHAR(255) NOT NULL, dest_name VARCHAR(255) NOT NULL, file_name VARCHAR(255) DEFAULT NULL, state VARCHAR(20) NOT NULL, hmac VARCHAR(128) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, sent_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, signed_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, refused_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, refused_reason TEXT DEFAULT NULL, path_pdf_unsigned VARCHAR(500) DEFAULT NULL, path_pdf_signed VARCHAR(500) DEFAULT NULL, path_pdf_signed_certificate VARCHAR(500) DEFAULT NULL, file_hmac VARCHAR(128) DEFAULT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY (id))');
|
||
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_1BD06C91C33F7837 ON sign_document (document_id)');
|
||
|
|
$this->addSql('CREATE TABLE sign_document_event (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, type VARCHAR(30) NOT NULL, detail TEXT DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, document_id INT NOT NULL, PRIMARY KEY (id))');
|
||
|
|
$this->addSql('CREATE INDEX IDX_D494C99C33F7837 ON sign_document_event (document_id)');
|
||
|
|
$this->addSql('CREATE TABLE sign_document_field (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, type VARCHAR(30) NOT NULL, label VARCHAR(255) NOT NULL, page INT NOT NULL, position_x DOUBLE PRECISION NOT NULL, position_y DOUBLE PRECISION NOT NULL, width DOUBLE PRECISION NOT NULL, height DOUBLE PRECISION NOT NULL, position INT NOT NULL, value TEXT DEFAULT NULL, filled_value TEXT DEFAULT NULL, filled_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, required BOOLEAN NOT NULL, document_id INT NOT NULL, signer_id INT DEFAULT NULL, filled_by_id INT DEFAULT NULL, PRIMARY KEY (id))');
|
||
|
|
$this->addSql('CREATE INDEX IDX_6D120366C33F7837 ON sign_document_field (document_id)');
|
||
|
|
$this->addSql('CREATE INDEX IDX_6D1203669588C067 ON sign_document_field (signer_id)');
|
||
|
|
$this->addSql('CREATE INDEX IDX_6D12036690409A66 ON sign_document_field (filled_by_id)');
|
||
|
|
$this->addSql('CREATE TABLE sign_document_signer (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, email VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, signing_order INT NOT NULL, state VARCHAR(20) NOT NULL, signed_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, refused_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, refused_reason TEXT DEFAULT NULL, token VARCHAR(64) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, document_id INT NOT NULL, PRIMARY KEY (id))');
|
||
|
|
$this->addSql('CREATE UNIQUE INDEX UNIQ_2B38977F5F37A13B ON sign_document_signer (token)');
|
||
|
|
$this->addSql('CREATE INDEX IDX_2B38977FC33F7837 ON sign_document_signer (document_id)');
|
||
|
|
$this->addSql('ALTER TABLE sign_document_event ADD CONSTRAINT FK_D494C99C33F7837 FOREIGN KEY (document_id) REFERENCES sign_document (id) ON DELETE CASCADE NOT DEFERRABLE');
|
||
|
|
$this->addSql('ALTER TABLE sign_document_field ADD CONSTRAINT FK_6D120366C33F7837 FOREIGN KEY (document_id) REFERENCES sign_document (id) ON DELETE CASCADE NOT DEFERRABLE');
|
||
|
|
$this->addSql('ALTER TABLE sign_document_field ADD CONSTRAINT FK_6D1203669588C067 FOREIGN KEY (signer_id) REFERENCES sign_document_signer (id) ON DELETE SET NULL NOT DEFERRABLE');
|
||
|
|
$this->addSql('ALTER TABLE sign_document_field ADD CONSTRAINT FK_6D12036690409A66 FOREIGN KEY (filled_by_id) REFERENCES sign_document_signer (id) ON DELETE SET NULL NOT DEFERRABLE');
|
||
|
|
$this->addSql('ALTER TABLE sign_document_signer ADD CONSTRAINT FK_2B38977FC33F7837 FOREIGN KEY (document_id) REFERENCES sign_document (id) ON DELETE CASCADE NOT DEFERRABLE');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function down(Schema $schema): void
|
||
|
|
{
|
||
|
|
// this down() migration is auto-generated, please modify it to your needs
|
||
|
|
$this->addSql('ALTER TABLE sign_document_event DROP CONSTRAINT FK_D494C99C33F7837');
|
||
|
|
$this->addSql('ALTER TABLE sign_document_field DROP CONSTRAINT FK_6D120366C33F7837');
|
||
|
|
$this->addSql('ALTER TABLE sign_document_field DROP CONSTRAINT FK_6D1203669588C067');
|
||
|
|
$this->addSql('ALTER TABLE sign_document_field DROP CONSTRAINT FK_6D12036690409A66');
|
||
|
|
$this->addSql('ALTER TABLE sign_document_signer DROP CONSTRAINT FK_2B38977FC33F7837');
|
||
|
|
$this->addSql('DROP TABLE sign_document');
|
||
|
|
$this->addSql('DROP TABLE sign_document_event');
|
||
|
|
$this->addSql('DROP TABLE sign_document_field');
|
||
|
|
$this->addSql('DROP TABLE sign_document_signer');
|
||
|
|
}
|
||
|
|
}
|