<?php
/*
 * This file is part of the WikiTagBundle package.
 *
 * (c) IRI <http://www.iri.centrepompidou.fr/>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Application\Migrations;

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

/**
 * Auto-generated Migration: Please modify to your need!
 */
class Version20111209060357 extends AbstractMigration
{
    public function up(Schema $schema)
    {
        // this up() migration is autogenerated, please modify it to your needs
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
        
        $this->addSql("ALTER TABLE wikitag_document ADD created_at DATETIME NULL");
        $this->addSql("ALTER TABLE wikitag_document_tag ADD created_at DATETIME NULL");
        $this->addSql("ALTER TABLE wikitag_tag ADD created_at DATETIME NULL");
        
        $this->addSql("UPDATE wikitag_document SET created_at = UTC_TIMESTAMP()");
        $this->addSql("UPDATE wikitag_document_tag SET created_at = UTC_TIMESTAMP()");
        $this->addSql("UPDATE wikitag_tag SET created_at = UTC_TIMESTAMP()");
        
        $this->addSql("ALTER TABLE wikitag_document MODIFY created_at DATETIME NOT NULL");
        $this->addSql("ALTER TABLE wikitag_document_tag MODIFY created_at DATETIME NOT NULL");
        $this->addSql("ALTER TABLE wikitag_tag MODIFY created_at DATETIME NOT NULL");
        
    }

    public function down(Schema $schema)
    {
        // this down() migration is autogenerated, please modify it to your needs
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
        
        $this->addSql("ALTER TABLE wikitag_document DROP created_at");
        $this->addSql("ALTER TABLE wikitag_document_tag DROP created_at");
        $this->addSql("ALTER TABLE wikitag_tag DROP created_at");
    }
}
