<?phpuseyii\db\Schema;useyii\db\Migration;classm200817_080729_operation_logextendsMigration{publicfunctioninit(){$this->db='db';parent::init();}publicfunctionsafeUp(){$tableOptions="COMMENT = '操作日志' CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB";$this->createTable('{{%common_operation_log}}',['id'=>$this->primaryKey(11),'method'=>$this->tinyInteger(1)->notNull()->defaultValue(0)->comment('0:get;1post'),'module'=>$this->string(50)->notNull()->defaultValue('')->comment('模块'),'controller'=>$this->string(50)->notNull()->defaultValue('')->comment('控制器'),'action'=>$this->string(50)->notNull()->defaultValue('')->comment('方法'),'ip'=>$this->string(16)->notNull()->defaultValue(''),'user_id'=>$this->integer(11)->defaultValue(0)->comment('根据提交模块不同对应人员不同'),'created_at'=>$this->integer(11)->notNull()->defaultValue(0)->comment('创建时间'),'description'=>$this->text()->null()->defaultValue(null)->comment('修改数据'),'table'=>$this->string(50)->notNull()->defaultValue('')->comment('操作表名称'),'type'=>$this->tinyInteger(1)->notNull()->defaultValue(0)->comment('类型0:INSERT;1:UPDATE;2:DELETE'),'source'=>$this->string(10)->null()->defaultValue('')->comment('设备来源'),'app_id'=>$this->string(10)->null()->defaultValue('')->comment('应用id'),'alter_id'=>$this->integer(11)->null()->defaultValue(0)->comment('修改相关数据的id')],$tableOptions);$this->createIndex('user_id','{{%common_operation_log}}',['user_id'],false);$this->createIndex('app_id','{{%common_operation_log}}',['app_id'],false);$this->createIndex('module','{{%common_operation_log}}',['module'],false);$this->createIndex('controller','{{%common_operation_log}}',['controller'],false);$this->createIndex('action','{{%common_operation_log}}',['action'],false);}publicfunctionsafeDown(){$this->dropIndex('user_id','{{%common_operation_log}}');$this->dropIndex('app_id','{{%common_operation_log}}');$this->dropIndex('module','{{%common_operation_log}}');$this->dropIndex('controller','{{%common_operation_log}}');$this->dropIndex('action','{{%common_operation_log}}');$this->dropTable('{{%common_operation_log}}');}}