1
0

m180109_222941_user_log.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use yii\db\Schema;
  3. use yii\db\Migration;
  4. class m180109_222941_user_log extends Migration
  5. {
  6. public function up()
  7. {
  8. $tableOptions = null;
  9. if ($this->db->driverName === 'mysql') {
  10. $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="后台操作记录"';
  11. }
  12. $this->createTable('{{%admin_log}}', [
  13. //'name'=>Schema::TYPE_STRING.'(200) PRIMARY KEY NOT NULL',
  14. 'id'=>Schema::TYPE_PK,
  15. 'admin_id'=>Schema::TYPE_INTEGER.'(10) UNSIGNED NOT NULL COMMENT "操作用户ID"',
  16. 'admin_name'=>Schema::TYPE_STRING.'(200) NOT NULL COMMENT "操作用户名"',
  17. 'addtime'=>Schema::TYPE_INTEGER.'(10) NOT NULL COMMENT "记录时间"',
  18. 'admin_ip'=>Schema::TYPE_STRING.'(200) NOT NULL COMMENT "操作用户IP"',
  19. 'admin_agent'=>Schema::TYPE_STRING.'(200) NOT NULL COMMENT "操作用户浏览器代理商"',
  20. 'title'=>Schema::TYPE_STRING.'(200) NOT NULL COMMENT "记录描述"',
  21. 'model'=>Schema::TYPE_STRING.'(200) NOT NULL COMMENT "操作模块(例:文章)"',
  22. 'type'=>Schema::TYPE_STRING.'(200) NOT NULL COMMENT "操作类型(例:添加)"',
  23. 'handle_id'=>Schema::TYPE_INTEGER.'(10) NOT NULL COMMENT "操作对象ID"',
  24. 'result'=>Schema::TYPE_TEXT.' NOT NULL COMMENT "操作结果"',
  25. 'addtime'=>Schema::TYPE_DATETIME.' NOT NULL COMMENT "操作时间"',
  26. 'describe'=>Schema::TYPE_TEXT.' NOT NULL COMMENT "备注"',
  27. ], $tableOptions);
  28. }
  29. public function down()
  30. {
  31. $this->dropTable('{{%admin_log}}');
  32. }
  33. }