m161102_090053_menu.php 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. use yii\db\Migration;
  3. class m161102_090053_menu extends Migration
  4. {
  5. public function up()
  6. {
  7. $this->execute('SET foreign_key_checks = 0');
  8. $this->createTable('{{%menu}}', [
  9. 'id' => 'INT(11) NOT NULL AUTO_INCREMENT',
  10. 'name' => 'VARCHAR(128) NOT NULL',
  11. 'parent' => 'INT(11) NULL',
  12. 'route' => 'VARCHAR(256) NULL',
  13. 'order' => 'INT(11) NULL',
  14. 'data' => 'TEXT NULL',
  15. 'icon' => 'VARCHAR(50) NULL',
  16. 'PRIMARY KEY (`id`)'
  17. ], "CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB");
  18. $this->createIndex('parent','{{%menu}}','parent',0);
  19. $this->addForeignKey('pop_menu_ibfk_1', '{{%menu}}', 'parent', '{{%menu}}', 'id', 'SET NULL', 'CASCADE' );
  20. $this->execute('SET foreign_key_checks = 1;');
  21. $this->execute('SET foreign_key_checks = 0');
  22. /* Table yii2cmf_menu */
  23. $this->batchInsert('{{%menu}}',['id','name','parent','route','order','data','icon'],[
  24. ['15','用户管理','33','/user/default/index','1','','fa-user'],
  25. ['16','路由管理','33','/rbac/route/index','3','','fa-link'],
  26. ['17','角色管理','33','/rbac/role/index','2','','fa-user-md'],
  27. ['22','文章列表','39','/article/index','1','',''],
  28. ['24','系统','','','1','','fa-cog'],
  29. ['25','系统配置','71','/config/default/index','1','',''],
  30. ['26','自定义配置','71','/config/custom/index','2','',''],
  31. ['27','单页管理','39','/page/index','39','',''],
  32. ['29','分类管理','39','/category/index','4','',''],
  33. ['30','数据库','','','7','','fa-book'],
  34. ['31','备份','30','/backup/export/index','1','',''],
  35. ['32','还原','30','/backup/import/index','2','',''],
  36. ['33','用户','','','4','','fa-users'],
  37. ['34','菜单管理','24','/rbac/menu/index','3','','fa-navicon'],
  38. ['37','操作记录','24','/admin-log/index','5','','fa-envelope-o'],
  39. ['39','内容','','','2','','fa-edit'],
  40. ['40','发布文章','39','/article/create','2','','fa-plus'],
  41. ['41','回收站','39','/article/trash','3','',''],
  42. ['42','评论管理','39','/comment/index','6','',''],
  43. ['43','留言板','39','/suggest/index','7','',''],
  44. ['44','插件','','','5','','fa-plug'],
  45. ['45','插件管理','44','/plugin/index','','',''],
  46. ['47','模块管理','44','/module/index','','',''],
  47. ['46','网站','','','3','','fa-desktop'],
  48. ['48','主题','46','/theme/default/index','4','',''],
  49. ['49','幻灯片','46','/carousel/index','5','',''],
  50. ['50','导航','46','/nav/index','1','',''],
  51. ['51','区域','46','/area/area/index','2','',''],
  52. ['52','区块','46','/area/block/index','3','',''],
  53. ['57','规则管理','33','/rbac/rule/index','5','','fa-sitemap'],
  54. ['58','权限管理','33','/rbac/permission/index','4','','fa-check-square'],
  55. ['66','群发站内信','46','/message/default/create','4','','fa-comment-o'],
  56. ['67','错误日志','24','/log/index','5','','fa-warning'],
  57. ['68','控制面板','24','/site/dashboard','1','','fa-dashboard'],
  58. ['69','GII','24','/gii/default/index','6','',''],
  59. ['70','迁移','24','/migration/default/index','7','','fa-external-link'],
  60. ['71','配置','','','6','',''],
  61. ['72','数据库配置','71','/config/default/database','3','',''],
  62. ['73','邮箱配置','71','/config/default/mail','4','',''],
  63. ['75','缓存','24','/cache/index','8','','fa-flash'],
  64. ['76','附件','39','/attachment/default/index','9','','fa-file-picture-o'],
  65. ['77','标签','39','/tag/index','10','','fa-tags'],
  66. ['78','路由规则','46','/urlrule/default/index','6','',''],
  67. ['79','国际化源信息','24','/i18n/i18n-source-message/index','8','',''],
  68. ['80','国际化信息','24','/i18n/i18n-message/index','9','',''],
  69. ]);
  70. $this->execute('SET foreign_key_checks = 1;');
  71. }
  72. public function down()
  73. {
  74. $this->execute('SET foreign_key_checks = 0');
  75. $this->dropTable('{{%menu}}');
  76. $this->execute('SET foreign_key_checks = 1;');
  77. }
  78. /*
  79. // Use safeUp/safeDown to run migration code within a transaction
  80. public function safeUp()
  81. {
  82. }
  83. public function safeDown()
  84. {
  85. }
  86. */
  87. }