m180110_155445_banner.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. use yii\db\Migration;
  3. use yii\db\Schema;
  4. /**
  5. * Class m180110_155445_banner
  6. */
  7. class m180110_155445_banner extends Migration
  8. {
  9. /**
  10. * @inheritdoc
  11. */
  12. public function safeUp()
  13. {
  14. }
  15. /**
  16. * @inheritdoc
  17. */
  18. public function safeDown()
  19. {
  20. echo "m180110_155445_banner cannot be reverted.\n";
  21. return false;
  22. }
  23. public function up()
  24. {
  25. $tableOptions = null;
  26. if ($this->db->driverName === 'mysql') {
  27. $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="轮播图"';
  28. }
  29. $this->createTable('{{%banner}}', [
  30. //'name'=>Schema::TYPE_STRING.'(200) PRIMARY KEY NOT NULL',
  31. 'id'=>Schema::TYPE_PK,
  32. 'status'=>Schema::TYPE_INTEGER.'(10) UNSIGNED NOT NULL COMMENT "状态"',
  33. 'title'=>Schema::TYPE_STRING.'(200) NOT NULL COMMENT "标题"',
  34. 'primaryKey'=>Schema::TYPE_STRING.'(200) NOT NULL COMMENT "关键值"',
  35. 'admin_id'=>Schema::TYPE_INTEGER.'(10) UNSIGNED NOT NULL COMMENT "操作用户ID"',
  36. 'admin_name'=>Schema::TYPE_STRING.'(200) NOT NULL COMMENT "操作用户名"',
  37. 'addtime'=>Schema::TYPE_INTEGER.'(10) NOT NULL COMMENT "记录时间"',
  38. 'admin_ip'=>Schema::TYPE_STRING.'(200) NOT NULL COMMENT "操作用户IP"',
  39. 'admin_agent'=>Schema::TYPE_STRING.'(200) NOT NULL COMMENT "操作用户浏览器代理商"',
  40. 'title'=>Schema::TYPE_STRING.'(200) NOT NULL COMMENT "记录描述"',
  41. 'model'=>Schema::TYPE_STRING.'(200) NOT NULL COMMENT "操作模块(例:文章)"',
  42. 'type'=>Schema::TYPE_STRING.'(200) NOT NULL COMMENT "操作类型(例:添加)"',
  43. 'handle_id'=>Schema::TYPE_INTEGER.'(10) NOT NULL COMMENT "操作对象ID"',
  44. 'result'=>Schema::TYPE_TEXT.' NOT NULL COMMENT "操作结果"',
  45. 'describe'=>Schema::TYPE_TEXT.' NOT NULL COMMENT "备注"',
  46. ], $tableOptions);
  47. }
  48. public function down()
  49. {
  50. $this->dropTable('{{%admin_log}}');
  51. }
  52. }