You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
web_edm/migrations/Version20240429144740.php

78 lines
7.1 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 Version20240429144740 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 ext_log_entries (id INT AUTO_INCREMENT NOT NULL, action VARCHAR(8) NOT NULL, logged_at DATETIME NOT NULL, object_id VARCHAR(64) DEFAULT NULL, object_class VARCHAR(191) NOT NULL, version INT NOT NULL, data LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\', username VARCHAR(191) DEFAULT NULL, INDEX log_class_lookup_idx (object_class), INDEX log_date_lookup_idx (logged_at), INDEX log_user_lookup_idx (username), INDEX log_version_lookup_idx (object_id, object_class, version), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC'
);
$this->addSql('CREATE TABLE ext_translations (id int AUTO_INCREMENT NOT NULL, locale varchar(8) NOT NULL, object_class varchar(191) NOT NULL, field varchar(32) NOT NULL, foreign_key varchar(64) NOT NULL, content longtext DEFAULT NULL, INDEX translations_lookup_idx (locale, object_class, foreign_key), INDEX general_translations_lookup_idx (object_class, foreign_key), UNIQUE INDEX lookup_unique_idx (locale, object_class, field, foreign_key), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC'
);
$this->addSql('CREATE TABLE tag_document (tag_id int NOT NULL, document_id int NOT NULL, INDEX IDX_EE58F1ADBAD26311 (tag_id), INDEX IDX_EE58F1ADC33F7837 (document_id), PRIMARY KEY(tag_id, document_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'
);
$this->addSql('ALTER TABLE tag_document ADD CONSTRAINT FK_EE58F1ADBAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE tag_document ADD CONSTRAINT FK_EE58F1ADC33F7837 FOREIGN KEY (document_id) REFERENCES document (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE document DROP FOREIGN KEY FK_D8698A76A76ED395');
$this->addSql('DROP INDEX IDX_D8698A76A76ED395 ON document');
$this->addSql('ALTER TABLE document ADD file_name VARCHAR(255) NOT NULL, ADD file_type VARCHAR(255) NOT NULL, ADD file_size NUMERIC(10, 0) NOT NULL, CHANGE user_id owner_id INT NOT NULL, CHANGE name file_path VARCHAR(255) NOT NULL, CHANGE modification last_modification DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\''
);
$this->addSql('ALTER TABLE document ADD CONSTRAINT FK_D8698A767E3C61F9 FOREIGN KEY (owner_id) REFERENCES user (id)');
$this->addSql('CREATE INDEX IDX_D8698A767E3C61F9 ON document (owner_id)');
$this->addSql('ALTER TABLE tag ADD owner_id INT NOT NULL, ADD parent_id INT DEFAULT NULL, ADD path LONGTEXT NOT NULL, ADD creation DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD last_modification DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\''
);
$this->addSql('ALTER TABLE tag ADD CONSTRAINT FK_389B7837E3C61F9 FOREIGN KEY (owner_id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE tag ADD CONSTRAINT FK_389B783727ACA70 FOREIGN KEY (parent_id) REFERENCES tag (id) ON DELETE CASCADE');
$this->addSql('CREATE INDEX IDX_389B7837E3C61F9 ON tag (owner_id)');
$this->addSql('CREATE INDEX IDX_389B783727ACA70 ON tag (parent_id)');
$this->addSql('DROP INDEX UNIQ_8D93D649F85E0677 ON user');
$this->addSql('ALTER TABLE user ADD validation_administrator_id INT DEFAULT NULL, ADD email VARCHAR(100) NOT NULL, ADD name VARCHAR(100) DEFAULT NULL, ADD validation_date DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD creation DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD last_modification DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', DROP username, CHANGE roles roles JSON NOT NULL COMMENT \'(DC2Type:json)\''
);
$this->addSql('ALTER TABLE user ADD CONSTRAINT FK_8D93D6495F4CC0C2 FOREIGN KEY (validation_administrator_id) REFERENCES user (id)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649E7927C74 ON user (email)');
$this->addSql('CREATE INDEX IDX_8D93D6495F4CC0C2 ON user (validation_administrator_id)');
$this->addSql('ALTER TABLE messenger_messages CHANGE created_at created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', CHANGE available_at available_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', CHANGE delivered_at delivered_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\''
);
}
public function down (Schema $schema): void {
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE tag_document DROP FOREIGN KEY FK_EE58F1ADBAD26311');
$this->addSql('ALTER TABLE tag_document DROP FOREIGN KEY FK_EE58F1ADC33F7837');
$this->addSql('DROP TABLE ext_log_entries');
$this->addSql('DROP TABLE ext_translations');
$this->addSql('DROP TABLE tag_document');
$this->addSql('ALTER TABLE document DROP FOREIGN KEY FK_D8698A767E3C61F9');
$this->addSql('DROP INDEX IDX_D8698A767E3C61F9 ON document');
$this->addSql('ALTER TABLE document ADD name VARCHAR(255) NOT NULL, DROP file_path, DROP file_name, DROP file_type, DROP file_size, CHANGE owner_id user_id INT NOT NULL, CHANGE last_modification modification DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\''
);
$this->addSql('ALTER TABLE document ADD CONSTRAINT FK_D8698A76A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('CREATE INDEX IDX_D8698A76A76ED395 ON document (user_id)');
$this->addSql('ALTER TABLE messenger_messages CHANGE created_at created_at datetime NOT NULL, CHANGE available_at available_at datetime NOT NULL, CHANGE delivered_at delivered_at datetime DEFAULT NULL'
);
$this->addSql('ALTER TABLE tag DROP FOREIGN KEY FK_389B7837E3C61F9');
$this->addSql('ALTER TABLE tag DROP FOREIGN KEY FK_389B783727ACA70');
$this->addSql('DROP INDEX IDX_389B7837E3C61F9 ON tag');
$this->addSql('DROP INDEX IDX_389B783727ACA70 ON tag');
$this->addSql('ALTER TABLE tag DROP owner_id, DROP parent_id, DROP path, DROP creation, DROP last_modification');
$this->addSql('ALTER TABLE user DROP FOREIGN KEY FK_8D93D6495F4CC0C2');
$this->addSql('DROP INDEX UNIQ_8D93D649E7927C74 ON user');
$this->addSql('DROP INDEX IDX_8D93D6495F4CC0C2 ON user');
$this->addSql('ALTER TABLE user ADD username VARCHAR(180) NOT NULL, DROP validation_administrator_id, DROP email, DROP name, DROP validation_date, DROP creation, DROP last_modification, CHANGE roles roles JSON NOT NULL COMMENT \'(DC2Type:json)\''
);
$this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649F85E0677 ON user (username)');
}
}