Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds in the functionality to delete db backups. #80

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 12 additions & 41 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/Commands/DbBackupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,30 @@ function (
$this->writeln(PHP_EOL);
$this->say(sprintf('Database backup downloaded to %s', $location));
}

/**
* Deletes a database backup.
*
* @param string $uuid
* @param string $environment
* @param string $dbName
* @param int $backupId
*
* @command database:backup:delete
* @aliases db:backup:delete
*/
public function dbBackupDelete(DatabaseBackups $databaseBackupsAdapter, $uuid, $environment, $dbName, $backupId)
{
$environment = $this->cloudapiService->getEnvironment($uuid, $environment);

if (
$this->confirm(
sprintf('Are you sure you want to delete backup id %s in %s?', $backupId, $environment->label)
)
) {
$this->say(sprintf('Deleting backup %s to %s on %s', $backupId, $dbName, $environment->label));
$response = $databaseBackupsAdapter->delete($environment->uuid, $dbName, $backupId);
$this->waitForNotification($response);
}
}
}
3 changes: 3 additions & 0 deletions tests/AcquiaCliTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ public static function getFixtureMap()
'get' => 'Logs/downloadLog.dat',
'post' => 'Logs/createLogSnapshot.json'
],
'/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470/databases/dbName/backups/1234' => [
'delete' => 'DatabaseBackups/deleteDatabaseBackup.json'
],
'/ides/215824ff-272a-4a8c-9027-df32ed1d68a9' => [
'delete' => 'Ides/deleteIde.json'
],
Expand Down
4 changes: 4 additions & 0 deletions tests/Commands/DbBackupCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ public function dbBackupProvider()
['database:backup:link', 'devcloud:devcloud2', 'dev', 'dbName', '1234'],
$dbLink . PHP_EOL
],
[
['database:backup:delete', 'devcloud:devcloud2', 'dev', 'dbName', '1234'],
'> Deleting backup 1234 to dbName on Dev' . PHP_EOL
],
];
}
}