m160516_021121_admin_menu.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. use yii\db\Migration;
  3. class m160516_021121_admin_menu extends Migration
  4. {
  5. public function up()
  6. {
  7. $sql1 = "CREATE TABLE IF NOT EXISTS `admin_menu` (
  8. `id` int(15) NOT NULL AUTO_INCREMENT,
  9. `name` varchar(150) DEFAULT NULL,
  10. `level` int(5) DEFAULT NULL,
  11. `parent_id` int(15) DEFAULT NULL,
  12. `url_key` varchar(255) DEFAULT NULL,
  13. `role_key` varchar(150) DEFAULT NULL COMMENT '权限key,也就是controller的路径,譬如/fecadmin/menu/managere,controller 是MenuController,当前的值为:/fecadmin/menu',
  14. `created_at` datetime DEFAULT NULL,
  15. `updated_at` datetime DEFAULT NULL,
  16. `sort_order` int(10) NOT NULL DEFAULT '0',
  17. `can_delete` int(5) DEFAULT '2' COMMENT '是否可以被删除,1代表不可以删除,2代表可以删除',
  18. PRIMARY KEY (`id`)
  19. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=179 ;
  20. ";
  21. $this->execute($sql1);
  22. $sql2 = "INSERT INTO `admin_menu` (`id`, `name`, `level`, `parent_id`, `url_key`, `role_key`, `created_at`, `updated_at`, `sort_order`, `can_delete`) VALUES
  23. (164, '控制面板', 1, 0, '/ddd', NULL, '2016-01-15 10:21:36', '2016-01-15 10:21:36', 0, 1),
  24. (165, '用户管理', 2, 164, '/ddd', NULL, '2016-01-15 10:23:01', '2016-01-15 10:23:01', 0, 1),
  25. (166, '菜单管理', 2, 164, '/fecadmin/menu/manager', '/fecadmin/menu', '2016-01-15 10:23:22', '2016-01-16 16:45:23', 0, 1),
  26. (167, '我的账户', 3, 165, '/fecadmin/myaccount/index', '/fecadmin/myaccount', '2016-01-15 10:24:29', '2016-01-16 16:07:58', 0, 1),
  27. (168, '账户管理', 3, 165, '/fecadmin/account/manager', '/fecadmin/account', '2016-01-15 10:24:51', '2016-01-21 15:24:18', 0, 1),
  28. (169, '权限管理', 3, 165, '/fecadmin/role/manager', '/fecadmin/role', '2016-01-15 10:25:10', '2016-01-21 13:22:39', 0, 1),
  29. (170, '操作日志', 2, 164, '/fecadmin/log/index', '/fecadmin/log', '2016-01-15 10:35:19', '2016-01-16 16:45:18', 0, 1),
  30. (171, '缓存管理', 2, 164, '/fecadmin/cache/index', '/fecadmin/cache', '2016-01-15 10:35:40', '2016-01-16 16:45:14', 0, 1),
  31. (177, 'CMS', 1, 0, '/x/x/x', '/x/x', '2016-07-11 21:16:56', '2016-07-16 09:32:30', 5, 2),
  32. (178, 'Article', 2, 177, '/cms/article/index', '/cms/article', '2016-07-11 21:17:17', '2016-07-11 21:17:17', 0, 2);
  33. ";
  34. $this->execute($sql2);
  35. }
  36. public function down()
  37. {
  38. echo "m160516_021121_admin_menu cannot be reverted.\n";
  39. return false;
  40. }
  41. /*
  42. // Use safeUp/safeDown to run migration code within a transaction
  43. public function safeUp()
  44. {
  45. }
  46. public function safeDown()
  47. {
  48. }
  49. */
  50. }