mirror of
https://github.com/pterodactyl/panel.git
synced 2024-11-22 17:12:30 +01:00
Fix migration to not require beta versions of MariaDB
This commit is contained in:
parent
568328596a
commit
2ac82af25a
@ -18,15 +18,21 @@ class MergePermissionsTableIntoSubusers extends Migration
|
||||
$table->json('permissions')->nullable()->after('server_id');
|
||||
});
|
||||
|
||||
DB::statement('
|
||||
UPDATE subusers as s
|
||||
LEFT JOIN (
|
||||
SELECT subuser_id, JSON_ARRAYAGG(permission) as permissions
|
||||
FROM permissions
|
||||
GROUP BY subuser_id
|
||||
) as p ON p.subuser_id = s.id
|
||||
SET s.permissions = p.permissions
|
||||
');
|
||||
$cursor = DB::table('permissions')
|
||||
->select(['subuser_id'])
|
||||
->selectRaw('GROUP_CONCAT(permission) as permissions')
|
||||
->from('permissions')
|
||||
->groupBy(['subuser_id'])
|
||||
->cursor();
|
||||
|
||||
DB::transaction(function () use (&$cursor) {
|
||||
$cursor->each(function ($datum) {
|
||||
DB::update('UPDATE subusers SET permissions = ? WHERE id = ?', [
|
||||
json_encode(explode(',', $datum->permissions)),
|
||||
$datum->subuser_id,
|
||||
]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user