Exemplo n.º 1
0
 public function __construct()
 {
     //创建migration表用于记录动作
     if (!Schema::tableExists('migrations')) {
         $sql = "CREATE TABLE " . c('database.prefix') . 'migrations(migration varchar(255) not null,batch int)CHARSET UTF8';
         Db::execute($sql);
     }
     if (empty(self::$batch)) {
         self::$batch = Db::table('migrations')->max('batch') ?: 0;
     }
 }
Exemplo n.º 2
0
    public function cache()
    {
        $table = c('database.prefix') . c('cache.mysql.table');
        if (Schema::tableExists(c('cache.mysql.table'))) {
            $this->error('Table already exists');
        }
        $sql = <<<sql
CREATE TABLE `{$table}` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` char(20) DEFAULT NULL,
  `data` mediumtext,
  `create_at` int(10),
  `expire` int(10),
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
sql;
        Schema::sql($sql);
    }