-
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.
refactor: delete backups when they are deleted
- Loading branch information
1 parent
38fd482
commit 53c601a
Showing
5 changed files
with
48 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,16 @@ | ||
#### Release Links | ||
* lagoon [v2.20.0](https://github.com/uselagoon/lagoon/releases/tag/v2.20.0) | ||
* lagoon-ui [core-v2.20.0](https://github.com/uselagoon/lagoon-ui/releases/tag/core-v2.20.0) | ||
* lagoon-build-deploy [core-v2.20.0](https://github.com/uselagoon/build-deploy-tool/releases/tag/core-v2.20.0) | ||
* lagoon-core chart [1.45.0](https://github.com/uselagoon/lagoon-charts/releases/tag/lagoon-core-1.45.0) | ||
* lagoon-remote chart [0.89.0](https://github.com/uselagoon/lagoon-charts/releases/tag/lagoon-remote-0.89.0) | ||
* lagoon-test chart: [0.57.0](https://github.com/uselagoon/lagoon-charts/releases/tag/lagoon-test-0.57.0) | ||
|
||
|
||
## 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/20240314000000_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