/** * Run the migrations. * * @return void */ public function up() { // 前面不需要使用use DB; $prefix = DB::getTablePrefix(); $table = $prefix.'text'; pf('create table: '.$table); $sql = " CREATE TABLE `$table` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `type` char(10) NOT NULL DEFAULT '' COMMENT '内容类型,answer 回答,question 问题,note 笔记', `cid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '内容ID', `created_at` timestamp NULL DEFAULT NULL COMMENT '内容创建时间', PRIMARY KEY (`id`), KEY `type` (`type`), KEY `cid` (`cid`), KEY `created_at` (`created_at`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='时间线分表:201712'; "; DB::getPdo()->exec($sql); } /** * Reverse the migrations. * * @return void */ public function down() { $prefix =DB::getTablePrefix(); $table = $prefix.'text'; $sql = "DROP TABLE $table"; DB::getPdo()->exec($sql); } }