<?php
/**
 * Generated: 2014-03-14 09:25:59
 * @author Rtn_Module_Tool
 */
class News_Module_Initer_DB extends Main_News_Module_Initer_DB {
	
	static function init() {
		empty(static::$sql_before) || R::exec(static::$sql_before);

		$sql = <<<EOF
			CREATE TABLE `newsentry` (
			  `id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
			  `active` tinyint NOT NULL,
			  `user_id` int(11) unsigned NOT NULL,
			  `dtpublished` datetime NOT NULL,
			  `title` varchar(128) NOT NULL,
			  `extension` varchar(10) NULL,
			  `body` text NOT NULL,
			  FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
			) COMMENT=''; -- 0.249 s
			
			CREATE OR REPLACE VIEW viewnewsentry AS
			SELECT 
				newsentry.*,
				user.name AS authorname
			FROM
				newsentry
			JOIN
				user ON (user.id = newsentry.user_id);
			
EOF;
		
		R::exec($sql);
		
		
		empty(static::$sql_after) || R::exec(static::$sql_after);
	}
	
}