framework/migrations/2021_05_10_000000_rename_permissions.php
Alexander Skvortsov d64750b3eb
Rename viewDiscussions => viewForum, viewUserList => searchUsers (#2854)
This naming is clearer as to the intended effect. Changes include:

- A migration to rename all permissions
- Updating the seed migration to use the original naming from the start
- Replacing usage of the old names with new names in code
- Throwing warnings when the old names are used.
2021-05-11 15:15:27 -04:00

37 lines
1.2 KiB
PHP

<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
use Illuminate\Database\Schema\Builder;
return [
'up' => function (Builder $schema) {
$db = $schema->getConnection();
$db->table('group_permission')
->where('permission', 'LIKE', 'viewDiscussions')
->update(['permission' => $db->raw("REPLACE(permission, 'viewDiscussions', 'viewForum')")]);
$db->table('group_permission')
->where('permission', 'LIKE', 'viewUserList')
->update(['permission' => $db->raw("REPLACE(permission, 'viewUserList', 'searchUsers')")]);
},
'down' => function (Builder $schema) {
$db = $schema->getConnection();
$db->table('group_permission')
->where('permission', 'LIKE', 'viewForum')
->update(['permission' => $db->raw("REPLACE(permission, 'viewForum', 'viewDiscussions')")]);
$db->table('group_permission')
->where('permission', 'LIKE', 'searchUsers')
->update(['permission' => $db->raw("REPLACE(permission, 'searchUsers', 'viewUserList')")]);
}
];