public $tableName = 'sms_template';
public function up()
{
$result = $this->db->createCommand('SELECT table_name FROM information_schema.TABLES WHERE table_name ="' . $this->tableName . '"')->queryAll();
if ($result) {
return true;
}
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=MyISAM';
}
$this->createTable(
$this->tableName,
[
'id' => $this->integer(5)->unsigned()->notNull()->comment('模板id'),
'name' => $this->string(32)->notNull()->defaultValue('0')->comment('模板名字')
],
$tableOptions
);
$this->addPrimaryKey('id', $this->tableName, 'id');
//处理枚举类型字段 enum
$this->addColumn($this->tableName, 'status', "enum('0','1') COLLATE utf8_unicode_ci DEFAULT '0' COMMENT '模板状态 0=失败,1=成功'");
$this->addColumn($this->tableName, 'is_delete', "enum('0','1') COLLATE utf8_unicode_ci DEFAULT '0' COMMENT '是否可删除 0=不可以 1=可以'");
}