<?php

namespace Application\Migrations;

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

/**
 * Auto-generated Migration: Please modify to your needs!
 */
class Version20160904150420 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() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

        $this->addSql('ALTER TABLE demandepee ADD external_registration_type VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE fos_user ALTER username TYPE VARCHAR(180)');
        $this->addSql('ALTER TABLE fos_user ALTER username_canonical TYPE VARCHAR(180)');
        $this->addSql('ALTER TABLE fos_user ALTER email TYPE VARCHAR(180)');
        $this->addSql('ALTER TABLE fos_user ALTER email_canonical TYPE VARCHAR(180)');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_957A6479C05FB297 ON fos_user (confirmation_token)');
    }

    /**
     * @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() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

        $this->addSql('ALTER TABLE DemandePEE DROP external_registration_type');
        $this->addSql('DROP INDEX UNIQ_957A6479C05FB297');
        $this->addSql('ALTER TABLE fos_user ALTER username TYPE VARCHAR(255)');
        $this->addSql('ALTER TABLE fos_user ALTER username_canonical TYPE VARCHAR(255)');
        $this->addSql('ALTER TABLE fos_user ALTER email TYPE VARCHAR(255)');
        $this->addSql('ALTER TABLE fos_user ALTER email_canonical TYPE VARCHAR(255)');
    }
}
