-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3679 from uselagoon/deprecate-deleted-backups
deprecation: delete backups when they are deleted
- Loading branch information
Showing
5 changed files
with
44 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#### Release Links | ||
|
||
!!! Info | ||
This version has not been released yet | ||
|
||
## Upgrades | ||
There are no required actions or considerations with this release. As always, we suggest upgrading all minor versions. | ||
|
||
## Deprecations | ||
|
||
### Deleted Backups | ||
* When a backup is deleted via the webhook, it will now actually removed from the API rather than being flagged as deleted. The `Backup` type field `deleted` is deprecated, and will be removed in a future release. Additionally, `includeDeleted` if requested when querying backups will not change the result as there will be no deleted backups to include. |
29 changes: 29 additions & 0 deletions
29
services/api/database/migrations/20240507000000_delete_orphaned_backup_resources.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.up = function(knex) { | ||
// remove any deleted environment backups that are flagged as deleted | ||
// or where the environment/project are deleted or no longer exist | ||
return knex.schema | ||
.raw(`DELETE eb | ||
FROM environment_backup eb | ||
LEFT JOIN environment e ON eb.environment = e.id | ||
WHERE eb.deleted != '0000-00-00 00:00:00' OR e.id IS NULL OR e.deleted != '0000-00-00 00:00:00' OR e.project NOT IN (SELECT id FROM project) | ||
`) | ||
// drop the deleted column | ||
.alterTable('environment_backup', (table) => { | ||
table.dropColumn('deleted'); | ||
}); | ||
}; | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = function(knex) { | ||
return knex.schema | ||
.alterTable('environment_backup', (table) => { | ||
table.timestamp('deleted').notNullable().defaultTo('0000-00-00 00:00:00'); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters