Fix migration to not require beta versions of MariaDB

This commit is contained in:
Dane Everitt 2020-04-10 14:09:57 -07:00
parent 568328596a
commit 2ac82af25a
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -18,15 +18,21 @@ class MergePermissionsTableIntoSubusers extends Migration
$table->json('permissions')->nullable()->after('server_id'); $table->json('permissions')->nullable()->after('server_id');
}); });
DB::statement(' $cursor = DB::table('permissions')
UPDATE subusers as s ->select(['subuser_id'])
LEFT JOIN ( ->selectRaw('GROUP_CONCAT(permission) as permissions')
SELECT subuser_id, JSON_ARRAYAGG(permission) as permissions ->from('permissions')
FROM permissions ->groupBy(['subuser_id'])
GROUP BY subuser_id ->cursor();
) as p ON p.subuser_id = s.id
SET s.permissions = p.permissions 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,
]);
});
});
} }
/** /**