Fix migration to not require beta versions of MariaDB
This commit is contained in:
parent
568328596a
commit
2ac82af25a
1 changed files with 15 additions and 9 deletions
|
@ -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,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue