<commit_before><?php

declare(strict_types=1);

namespace ShlinkMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;

final class Version20200323190014 extends AbstractMigration
{
    public function up(Schema $schema): void
    {
        $visitLocations = $schema->getTable('visit_locations');
        $this->skipIf($visitLocations->hasColumn('is_empty'));

        $visitLocations->addColumn('is_empty', Types::BOOLEAN, ['default' => false]);
    }

    public function postUp(Schema $schema): void
    {
        $qb = $this->connection->createQueryBuilder();
        $qb->update('visit_locations')
           ->set('is_empty', true)
           ->where($qb->expr()->eq('country_code', ':empty'))
           ->andWhere($qb->expr()->eq('country_name', ':empty'))
           ->andWhere($qb->expr()->eq('region_name', ':empty'))
           ->andWhere($qb->expr()->eq('city_name', ':empty'))
           ->andWhere($qb->expr()->eq('timezone', ':empty'))
           ->andWhere($qb->expr()->eq('lat', 0))
           ->andWhere($qb->expr()->eq('lon', 0))
           ->setParameter('empty', '')
           ->execute();
    }

    public function down(Schema $schema): void
    {
        $visitLocations = $schema->getTable('visit_locations');
        $this->skipIf(!$visitLocations->hasColumn('is_empty'));

        $visitLocations->dropColumn('is_empty');
    }
}<commit_msg>Fixed query in migration for postgres<commit_after><?php

declare(strict_types=1);

namespace ShlinkMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;

final class Version20200323190014 extends AbstractMigration
{
    public function up(Schema $schema): void
    {
        $visitLocations = $schema->getTable('visit_locations');
        $this->skipIf($visitLocations->hasColumn('is_empty'));

        $visitLocations->addColumn('is_empty', Types::BOOLEAN, ['default' => false]);
    }

    public function postUp(Schema $schema): void
    {
        $qb = $this->connection->createQueryBuilder();
        $qb->update('visit_locations')
           ->set('is_empty', ':isEmpty')
           ->where($qb->expr()->eq('country_code', ':emptyString'))
           ->andWhere($qb->expr()->eq('country_name', ':emptyString'))
           ->andWhere($qb->expr()->eq('region_name', ':emptyString'))
           ->andWhere($qb->expr()->eq('city_name', ':emptyString'))
           ->andWhere($qb->expr()->eq('timezone', ':emptyString'))
           ->andWhere($qb->expr()->eq('lat', 0))
           ->andWhere($qb->expr()->eq('lon', 0))
           ->setParameter('isEmpty', true)
           ->setParameter('emptyString', '')
           ->execute();
    }

    public function down(Schema $schema): void
    {
        $visitLocations = $schema->getTable('visit_locations');
        $this->skipIf(!$visitLocations->hasColumn('is_empty'));

        $visitLocations->dropColumn('is_empty');
    }
}
{'fraction_non_alphanumeric': 0.19066800939912723, 'fraction_numerical': 0.011413225914736489, 'mean_word_length': 3.318840579710145, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 76, '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': '3300556', 'n_tokens_mistral': 935, 'n_tokens_neox': 892, 'n_words': 131}