Skip to content
Snippets Groups Projects

#286 Refacto LoggableSubject to distinct table

Merged #286 Refacto LoggableSubject to distinct table
All threads resolved!
Merged Loïc PROUST requested to merge feature/286_refacto_loggable_subject into lot-3
All threads resolved!
1 file
+ 17
17
Compare changes
  • Side-by-side
  • Inline
@@ -12,34 +12,34 @@ use Doctrine\Migrations\AbstractMigration;
*/
final class Version20200702140458 extends AbstractMigration
{
public function getDescription() : string
public function getDescription(): string
{
return '';
}
public function up(Schema $schema) : void
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$keyArray = [
'maturity_survey' => 'survey',
'registry_request' => "request",
'registry_violation' => "violation",
'registry_proof' => "proof",
'registry_mesurement' => "mesurement",
'registry_conformite_organisation_evaluation' => "evaluation",
'registry_contractor' => "contractor",
'conformite_traitement' => "conformite_traitement",
'registry_treatment' => "treatement",
'user_collectivity' => "collectivity",
'user_user' => "user",
'maturity_survey' => 'survey',
'registry_request' => 'request',
'registry_violation' => 'violation',
'registry_proof' => 'proof',
'registry_mesurement' => 'mesurement',
'registry_conformite_organisation_evaluation' => 'evaluation',
'registry_contractor' => 'contractor',
'conformite_traitement' => 'conformite_traitement',
'registry_treatment' => 'treatement',
'user_collectivity' => 'collectivity',
'user_user' => 'user',
];
$this->addSql('CREATE TABLE loggable_subject (id CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', discr VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
foreach ($keyArray as $key => $discr) {
$this->addSql("INSERT INTO loggable_subject (id, discr) SELECT id, '" . $discr ."' FROM " . $key);
$this->addSql("INSERT IGNORE INTO loggable_subject (id, discr) SELECT id, '" . $discr . "' FROM " . $key);
}
$this->addSql('ALTER TABLE maturity_survey ADD CONSTRAINT FK_E279C54ABF396750 FOREIGN KEY (id) REFERENCES loggable_subject (id) ON DELETE CASCADE');
@@ -56,10 +56,10 @@ final class Version20200702140458 extends AbstractMigration
$this->addSql('ALTER TABLE reporting_log_journal ADD CONSTRAINT FK_87AE0D7D23EDC87 FOREIGN KEY (subject_id) REFERENCES loggable_subject (id)');
}
public function down(Schema $schema) : void
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE maturity_survey DROP FOREIGN KEY FK_E279C54ABF396750');
$this->addSql('ALTER TABLE registry_request DROP FOREIGN KEY FK_3CDC30CDBF396750');
Loading