<?php

namespace Surfnet\StepupMiddleware\Migrations;

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

/**
 * Auto-generated Migration: Please modify to your needs!
 */
class Version20180330094402 extends AbstractMigration
{
    /**
     * @param Schema $schema
     */
    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 institution_configuration_options CHANGE verify_email_option verify_email_option TINYINT(1) DEFAULT \'1\' NOT NULL');
        $this->addSql('UPDATE institution_configuration_options SET verify_email_option = 1');
    }

    /**
     * @param Schema $schema
     */
    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 institution_configuration_options CHANGE verify_email_option verify_email_option TINYINT(1) NOT NULL');
    }
}

<?php

namespace Surfnet\StepupMiddleware\Migrations;

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

/**
 * Auto-generated Migration: Please modify to your needs!
 */
class Version20180330094402 extends AbstractMigration
{
    /**
     * @param Schema $schema
     */
    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 institution_configuration_options CHANGE verify_email_option verify_email_option TINYINT(1) DEFAULT \'1\' NOT NULL');
    }

    /**
     * @param Schema $schema
     */
    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 institution_configuration_options CHANGE verify_email_option verify_email_option TINYINT(1) NOT NULL');
    }
}

Remove possibly risky update query
Remove possibly risky update query

While fixing a default value bug[1] for the email verification
configuration option, the additional UPDATE query in the migration
(Version20180330094402) was not removed. This is risky and not necessary
as the default value is set in the ALTER TABLE and the column is not
nullable.

This issue was identified during review of the changes described in the
associated PR. The fix for this migration was boyscouted.

See:
1. https://github.com/OpenConext/Stepup-Middleware/pull/215
