Skip to content

Commit

Permalink
Merge pull request #1 from youyiyiper/master
Browse files Browse the repository at this point in the history
修复不支持表前缀的bug
  • Loading branch information
liulipeng authored Dec 20, 2017
2 parents 8c7bfed + 90223c8 commit fd62c95
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions migrations/m160712_111327_create_menu_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,16 @@ public function safeUp()
]
]);

$sql = "INSERT INTO `auth_item` (`name`, `type`, `description`, `rule_name`, `data`, `created_at`, `updated_at`) VALUES
//获取表前缀
$config = Configs::instance();
$tablePrefix = '';
if(!empty($config->db)){
$db = $config->db;
if(!empty($db->tablePrefix)){
$tablePrefix = $db->tablePrefix;
}
}
$sql = "INSERT INTO `".$tablePrefix."auth_item` (`name`, `type`, `description`, `rule_name`, `data`, `created_at`, `updated_at`) VALUES
('/admin/*', 2, NULL, NULL, NULL, 1457330826, 1457330826),
('/admin/assignment/*', 2, NULL, NULL, NULL, 1457330826, 1457330826),
('/admin/assignment/assign', 2, NULL, NULL, NULL, 1457330826, 1457330826),
Expand Down Expand Up @@ -167,10 +176,10 @@ public function safeUp()
('路由管理', 2, NULL, NULL, NULL, 1457331368, 1457331368);";
$this->execute($sql);

$sql = "INSERT INTO `auth_assignment` VALUES ('Admin','1',1457092343);";
$sql = "INSERT INTO `".$tablePrefix."auth_assignment` VALUES ('Admin','1',1457092343);";
$this->execute($sql);

$sql = "INSERT INTO `auth_item_child` (`parent`, `child`) VALUES
$sql = "INSERT INTO `".$tablePrefix."auth_item_child` (`parent`, `child`) VALUES
('用户权限分配', '/admin/assignment/assign'),
('新增用户', '/admin/assignment/create'),
('用户管理', '/admin/assignment/index'),
Expand Down

0 comments on commit fd62c95

Please sign in to comment.