<commit_before><?php

namespace Migrations;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Migrations\AbortMigrationException;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
class Version20181211142808 extends AbstractMigration
{
  /**
   * @param Schema $schema
   * @throws AbortMigrationException
   */
  public function up(Schema $schema)
  {
    // 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->addSql('ALTER TABLE test_result ADD used_memory_limit INT NOT NULL, ADD used_wall_time_limit DOUBLE PRECISION NOT NULL, ADD used_cpu_time_limit DOUBLE PRECISION NOT NULL');
  }

  /**
   * @param Schema $schema
   * @throws DBALException
   */
  public function postUp(Schema $schema)
  {
    // compute limits from used memory and time using stored ratios
    $this->connection->executeQuery("UPDATE test_result
      SET used_memory_limit = used_memory / used_memory_ratio,
          used_wall_time_limit = ROUND(used_wall_time / used_wall_time_ratio, 3),
          used_cpu_time_limit = ROUND(used_cpu_time / used_cpu_time_ratio, 3)");
  }

  /**
   * @param Schema $schema
   * @throws AbortMigrationException
   */
  public function down(Schema $schema)
  {
    // 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->addSql('ALTER TABLE test_result DROP used_memory_limit, DROP used_wall_time_limit, DROP used_cpu_time_limit');
  }
}<commit_msg>Bugfix: new versions of mariadb throws error on division by zero, do not use it in ratio-to-limit migration<commit_after><?php

namespace Migrations;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Migrations\AbortMigrationException;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
class Version20181211142808 extends AbstractMigration
{
  /**
   * @param Schema $schema
   * @throws AbortMigrationException
   */
  public function up(Schema $schema)
  {
    // 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->addSql('ALTER TABLE test_result ADD used_memory_limit INT NOT NULL, ADD used_wall_time_limit DOUBLE PRECISION NOT NULL, ADD used_cpu_time_limit DOUBLE PRECISION NOT NULL');
  }

  /**
   * @param Schema $schema
   * @throws DBALException
   */
  public function postUp(Schema $schema)
  {
    // compute limits from used memory and time using stored ratios
    $this->connection->executeQuery("UPDATE test_result
      SET used_memory_limit = LEAST(used_memory / GREATEST(used_memory_ratio, 0.00001), 4000008),
          used_wall_time_limit = ROUND(used_wall_time / GREATEST(used_wall_time_ratio, 0.00001), 3),
          used_cpu_time_limit = ROUND(used_cpu_time / GREATEST(used_cpu_time_ratio, 0.00001), 3)");
  }

  /**
   * @param Schema $schema
   * @throws AbortMigrationException
   */
  public function down(Schema $schema)
  {
    // 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->addSql('ALTER TABLE test_result DROP used_memory_limit, DROP used_wall_time_limit, DROP used_cpu_time_limit');
  }
}
{'fraction_non_alphanumeric': 0.10834437086092716, 'fraction_numerical': 0.015099337748344372, 'mean_word_length': 4.281118881118881, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3729887', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1140, 'n_words': 309}