<?php

class m130429_123906_add_violation_preview_table extends MyDbMigration
{
  public function up()
  {
    if ($this->dbConnection->schema->getTable('violation_document') === null)
    {
      $this->execute(
        "CREATE TABLE `violation_document` (
          `id` bigint(20) NOT NULL auto_increment,
          `id_event_behavior` bigint(20) default NULL,
          `status` char(250) default NULL,
          `document` mediumblob,
          `document_size` bigint(20) default NULL,
          `document_filename` char(250) default NULL,
          `last_update` datetime default NULL,
          `epoch` datetime default NULL,
          PRIMARY KEY  (`id`)
        ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"
      );
    }
  }

  public function down()
  {
    if ($this->dbConnection->schema->getTable('violation_document') !== null)
      $this->dropTable('violation_document');
  }

}
