<?php

/**
 * Generated: 2014-03-19 13:31:31
 * @author Rtn_Module_Tool
 */
class Gallery_Module_Initer_DB {

    static $sql_before = "
        DROP TABLE IF EXISTS `gallery`;
		CREATE TABLE `gallery` (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `name` varchar(300) COLLATE utf8_unicode_ci NOT NULL,
        `description` text COLLATE utf8_unicode_ci NOT NULL,
        `created` date NOT NULL,
        `update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
        `active` tinyint(3) unsigned DEFAULT NULL,
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
	";
    static $sql_after = "
        DROP TABLE IF EXISTS `image`;
        CREATE TABLE `image` (
        `id` int(11) NOT NULL AUTO_INCREMENT,
        `o` int(11) NOT NULL,
        `galleryid` int(11) NOT NULL,
        `created` date NOT NULL,
        `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
        `order` tinyint(3) unsigned DEFAULT NULL,
        PRIMARY KEY (`id`),
        KEY `galleryid` (`galleryid`),
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
	";

    static function init() {
        empty(static::$sql_before) || R::exec(static::$sql_before);
        empty(static::$sql_after) || R::exec(static::$sql_after);
    }

}
