Use new migration helper

This commit is contained in:
Toby Zerner 2017-07-22 12:19:29 +09:30
parent 0e470a91da
commit 1f258c362a

View File

@ -9,23 +9,9 @@
* file that was distributed with this source code.
*/
use Illuminate\Database\ConnectionInterface;
use Flarum\Core\Group;
use Flarum\Database\Migration;
$permissionAttributes = [
'group_id' => 3, // Default group ID of members
'permission' => 'discussion.likePosts',
];
return [
'up' => function (ConnectionInterface $db) use ($permissionAttributes) {
$instance = $db->table('permissions')->where($permissionAttributes)->first();
if (is_null($instance)) {
$db->table('permissions')->insert($permissionAttributes);
}
},
'down' => function (ConnectionInterface $db) use ($permissionAttributes) {
$db->table('permissions')->where($permissionAttributes)->delete();
}
];
return Migration::addPermissions([
'discussion.likePosts' => Group::MEMBER_ID
]);