Delete databases when we delete a server.

This commit is contained in:
Dane Everitt 2016-10-23 19:21:57 -04:00
parent 08b236ac1d
commit 55c9f0f2f2
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -788,6 +788,14 @@ class ServerRepository
// Remove Downloads
Models\Download::where('server', $server->uuid)->delete();
// Delete Databases
$databases = Models\Database::select('id')->where('server_id', $server->id)->get();
$repository = new DatabaseRepository;
foreach($databases as &$database) {
// Use the repository to drop the database, we don't need to delete here because it is now gone.
$repository->drop($database->id);
}
$client = Models\Node::guzzleRequest($server->node);
$client->request('DELETE', '/servers', [
'headers' => [