m160728_025305_create_config_table.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Handles the creation for table `{{%config}}`.
  5. */
  6. class m160728_025305_create_config_table extends Migration
  7. {
  8. /**
  9. * @inheritdoc
  10. */
  11. public function up()
  12. {
  13. $tableOptions = null;
  14. if ($this->db->driverName === 'mysql') {
  15. $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';
  16. }
  17. // config
  18. $this->createTable('{{%config}}', [
  19. 'id' => $this->primaryKey(),
  20. 'name' => $this->string(50)->notNull()->comment('配置名'),
  21. 'value' => $this->text()->comment('配置值'),
  22. 'extra' => $this->text()->notNull(),
  23. 'description' => $this->string(255)->comment('配置描述'),
  24. 'type' => $this->string(30)->defaultValue('text')->comment('配置类型'),
  25. 'created_at' => $this->integer(10)->notNull(),
  26. 'updated_at' => $this->integer(10)->notNull(),
  27. 'group' => $this->string(30)->defaultValue('system')->comment('配置分组')
  28. ], $tableOptions);
  29. $this->execute(<<<SQL
  30. INSERT INTO {{%config}} VALUES (1,'config_type_list','text=>字符\r\narray=>数组\r\npassword=>密码\r\nimage=>图片\r\ntextarea=>多行字符\r\nselect=>下拉框\r\nradio=>单选框\r\ncheckbox=>多选框\r\neditor=>富文本编辑器','','配置类型列表','array',0,1461937892,'system'),
  31. (2,'config_group','site=>网站\r\nsystem=>系统','','配置分组','array',1468405444,1468421137,'system'),
  32. (3,'site_name','yii2cmf','','网站名称','text',0,1461937892,'site'),
  33. (4,'site_icp','','','域名备案号','text',0,1461937892,'site'),
  34. (5,'site_logo','','','网站LOGO','image',0,1461937892,'site'),
  35. (6,'seo_site_description','yiicmf2','','meta description','text',0,1468403120,'site'),
  36. (7,'seo_site_keywords','yiicmf','','meta keywords','text',0,1461937892,'site'),
  37. (8,'theme_name','basic','','主题名','text',0,1467882452,'site'),
  38. (9,'backend_skin','skin-black','skin-black=>skin-black\r\nskin-black-light=>skin-black-light\r\nskin-blue=>skin-blue\r\nskin-blue-light=>skin-blue-light\r\nskin-green=>skin-green\r\nskin-green-light=>skin-green-light\r\nskin-purple=>skin-purple\r\nskin-pruple-light=>skin-purple-light\r\nskin-red=>skin-red\r\nskin-red-light=>skin-red-light\r\nskin-yellow=>skin-yellow\r\nskin-yellow-light=>skin-yellow-light','后台皮肤','select',1461931367,1461937892,'system'),
  39. (10,'editor_type_list','ueditor=>ueditor\r\nmarkdown=>markdown\r\nredactor=>redactor','','支持的编辑器类型','array',0,1468406411,'system'),
  40. (11,'article_editor_type','ueditor','editor_type_list','文章编辑器','select',0,1468406411,'system'),
  41. (12,'page_editor_type','ueditor','editor_type_list','单页编辑器','select',0,1468406411,'system');
  42. SQL
  43. );
  44. }
  45. /**
  46. * @inheritdoc
  47. */
  48. public function down()
  49. {
  50. $this->dropTable('{{%config}}');
  51. }
  52. }