<?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 Version20230710130045 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_type_tag (id INT NOT NULL, document_id INT DEFAULT NULL, is_required TINYINT(1) DEFAULT NULL, INDEX IDX_8E5FA03BC33F7837 (document_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE entity_type_tag (id INT NOT NULL, user_file_person_id INT DEFAULT NULL, user_file_person_revenue_id INT DEFAULT NULL, user_file_property_id INT DEFAULT NULL, user_file_property_credit_id INT DEFAULT NULL, user_file_investment_id INT DEFAULT NULL, user_file_credit_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_A36AED22C4F1DB68 (user_file_person_id), UNIQUE INDEX UNIQ_A36AED22E00338F0 (user_file_person_revenue_id), UNIQUE INDEX UNIQ_A36AED22B3CAF53 (user_file_property_id), UNIQUE INDEX UNIQ_A36AED2258A5FF00 (user_file_property_credit_id), UNIQUE INDEX UNIQ_A36AED22CF915DAB (user_file_investment_id), UNIQUE INDEX UNIQ_A36AED222B8C4FD6 (user_file_credit_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE tag (id INT AUTO_INCREMENT NOT NULL, user_file_id INT NOT NULL, discr VARCHAR(255) NOT NULL, INDEX IDX_389B783CBC66766 (user_file_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user_file_document_tag (user_file_document_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_8BA245C69C91C488 (user_file_document_id), INDEX IDX_8BA245C6BAD26311 (tag_id), PRIMARY KEY(user_file_document_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user_file_missing_files_tag (user_file_missing_files_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_658DC2DFBD77F18A (user_file_missing_files_id), INDEX IDX_658DC2DFBAD26311 (tag_id), PRIMARY KEY(user_file_missing_files_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE document_type_tag ADD CONSTRAINT FK_8E5FA03BC33F7837 FOREIGN KEY (document_id) REFERENCES `document` (id)');
$this->addSql('ALTER TABLE document_type_tag ADD CONSTRAINT FK_8E5FA03BBF396750 FOREIGN KEY (id) REFERENCES tag (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE entity_type_tag ADD CONSTRAINT FK_A36AED22C4F1DB68 FOREIGN KEY (user_file_person_id) REFERENCES user_file_person (id)');
$this->addSql('ALTER TABLE entity_type_tag ADD CONSTRAINT FK_A36AED22E00338F0 FOREIGN KEY (user_file_person_revenue_id) REFERENCES user_file_person_revenue (id)');
$this->addSql('ALTER TABLE entity_type_tag ADD CONSTRAINT FK_A36AED22B3CAF53 FOREIGN KEY (user_file_property_id) REFERENCES user_file_property (id)');
$this->addSql('ALTER TABLE entity_type_tag ADD CONSTRAINT FK_A36AED2258A5FF00 FOREIGN KEY (user_file_property_credit_id) REFERENCES user_file_property_credit (id)');
$this->addSql('ALTER TABLE entity_type_tag ADD CONSTRAINT FK_A36AED22CF915DAB FOREIGN KEY (user_file_investment_id) REFERENCES user_file_investment (id)');
$this->addSql('ALTER TABLE entity_type_tag ADD CONSTRAINT FK_A36AED222B8C4FD6 FOREIGN KEY (user_file_credit_id) REFERENCES user_file_credit (id)');
$this->addSql('ALTER TABLE entity_type_tag ADD CONSTRAINT FK_A36AED22BF396750 FOREIGN KEY (id) REFERENCES tag (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE tag ADD CONSTRAINT FK_389B783CBC66766 FOREIGN KEY (user_file_id) REFERENCES user_file (id)');
$this->addSql('ALTER TABLE user_file_document_tag ADD CONSTRAINT FK_8BA245C69C91C488 FOREIGN KEY (user_file_document_id) REFERENCES user_file_document (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE user_file_document_tag ADD CONSTRAINT FK_8BA245C6BAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE user_file_missing_files_tag ADD CONSTRAINT FK_658DC2DFBD77F18A FOREIGN KEY (user_file_missing_files_id) REFERENCES user_file_missing_files (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE user_file_missing_files_tag ADD CONSTRAINT FK_658DC2DFBAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE step DROP template');
$this->addSql('ALTER TABLE survey_document ADD is_mandatory TINYINT(1) DEFAULT NULL');
$this->addSql('ALTER TABLE user_file_document ADD user_file_id INT DEFAULT NULL, CHANGE document_group_id document_group_id INT DEFAULT NULL, CHANGE valid_state valid_state TINYINT(1) DEFAULT NULL');
$this->addSql('ALTER TABLE user_file_document ADD CONSTRAINT FK_87B7A8BBCBC66766 FOREIGN KEY (user_file_id) REFERENCES user_file (id)');
$this->addSql('CREATE INDEX IDX_87B7A8BBCBC66766 ON user_file_document (user_file_id)');
$this->addSql('ALTER TABLE user_file_document_information ADD document_type_tag_id INT DEFAULT NULL, ADD entity_type_tag_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE user_file_document_information ADD CONSTRAINT FK_5718F15C1BAC3F43 FOREIGN KEY (document_type_tag_id) REFERENCES document_type_tag (id)');
$this->addSql('ALTER TABLE user_file_document_information ADD CONSTRAINT FK_5718F15C1B3F52FA FOREIGN KEY (entity_type_tag_id) REFERENCES entity_type_tag (id)');
$this->addSql('CREATE INDEX IDX_5718F15C1BAC3F43 ON user_file_document_information (document_type_tag_id)');
$this->addSql('CREATE INDEX IDX_5718F15C1B3F52FA ON user_file_document_information (entity_type_tag_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user_file_document_information DROP FOREIGN KEY FK_5718F15C1BAC3F43');
$this->addSql('ALTER TABLE user_file_document_information DROP FOREIGN KEY FK_5718F15C1B3F52FA');
$this->addSql('ALTER TABLE document_type_tag DROP FOREIGN KEY FK_8E5FA03BC33F7837');
$this->addSql('ALTER TABLE document_type_tag DROP FOREIGN KEY FK_8E5FA03BBF396750');
$this->addSql('ALTER TABLE entity_type_tag DROP FOREIGN KEY FK_A36AED22C4F1DB68');
$this->addSql('ALTER TABLE entity_type_tag DROP FOREIGN KEY FK_A36AED22E00338F0');
$this->addSql('ALTER TABLE entity_type_tag DROP FOREIGN KEY FK_A36AED22B3CAF53');
$this->addSql('ALTER TABLE entity_type_tag DROP FOREIGN KEY FK_A36AED2258A5FF00');
$this->addSql('ALTER TABLE entity_type_tag DROP FOREIGN KEY FK_A36AED22CF915DAB');
$this->addSql('ALTER TABLE entity_type_tag DROP FOREIGN KEY FK_A36AED222B8C4FD6');
$this->addSql('ALTER TABLE entity_type_tag DROP FOREIGN KEY FK_A36AED22BF396750');
$this->addSql('ALTER TABLE tag DROP FOREIGN KEY FK_389B783CBC66766');
$this->addSql('ALTER TABLE user_file_document_tag DROP FOREIGN KEY FK_8BA245C69C91C488');
$this->addSql('ALTER TABLE user_file_document_tag DROP FOREIGN KEY FK_8BA245C6BAD26311');
$this->addSql('ALTER TABLE user_file_missing_files_tag DROP FOREIGN KEY FK_658DC2DFBD77F18A');
$this->addSql('ALTER TABLE user_file_missing_files_tag DROP FOREIGN KEY FK_658DC2DFBAD26311');
$this->addSql('DROP TABLE document_type_tag');
$this->addSql('DROP TABLE entity_type_tag');
$this->addSql('DROP TABLE tag');
$this->addSql('DROP TABLE user_file_document_tag');
$this->addSql('DROP TABLE user_file_missing_files_tag');
$this->addSql('ALTER TABLE step ADD template VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE survey_document DROP is_mandatory');
$this->addSql('ALTER TABLE user_file_document DROP FOREIGN KEY FK_87B7A8BBCBC66766');
$this->addSql('DROP INDEX IDX_87B7A8BBCBC66766 ON user_file_document');
$this->addSql('ALTER TABLE user_file_document DROP user_file_id, CHANGE document_group_id document_group_id INT NOT NULL, CHANGE valid_state valid_state SMALLINT DEFAULT NULL');
$this->addSql('DROP INDEX IDX_5718F15C1BAC3F43 ON user_file_document_information');
$this->addSql('DROP INDEX IDX_5718F15C1B3F52FA ON user_file_document_information');
$this->addSql('ALTER TABLE user_file_document_information DROP document_type_tag_id, DROP entity_type_tag_id');
}
}