app/DoctrineMigrations/Version20111209060357.php
author ymh <ymh.work@gmail.com>
Fri, 09 Dec 2011 06:43:49 +0100
changeset 57 b36a42d260d8
child 58 624e5900f5a4
permissions -rw-r--r--
add creation timestamp on document tag and document tag

<?php

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 createdAt DATETIME NULL");
        $this->addSql("ALTER TABLE wikitag_document_tag ADD createdAt DATETIME NULL");
        $this->addSql("ALTER TABLE wikitag_tag ADD createdAt DATETIME NULL");
        
        $this->addSql("UPDATE wikitag_document SET createdAt = UTC_TIMESTAMP()");
        $this->addSql("UPDATE wikitag_document_tag SET createdAt = UTC_TIMESTAMP()");
        $this->addSql("UPDATE wikitag_tag SET createdAt = UTC_TIMESTAMP()");
        
        $this->addSql("ALTER TABLE wikitag_document MODIFY createdAt DATETIME NOT NULL");
        $this->addSql("ALTER TABLE wikitag_document_tag MODIFY createdAt DATETIME NOT NULL");
        $this->addSql("ALTER TABLE wikitag_tag MODIFY createdAt 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 createdAt");
        $this->addSql("ALTER TABLE wikitag_document_tag DROP createdAt");
        $this->addSql("ALTER TABLE wikitag_tag DROP createdAt");
    }
}