-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor listen deletion status column (#3187)
* Refactor listen deletion status column Change boolean deleted column of listen_delete_metadata to status column which is an enum supporting pending, invalid and complete state. This helps mark duplicate listen delete requests and non existent listen delete requests as invalid and their subsequent cleanup after dumps finish. It's difficult to distinguish between a new listen deletion request and an invalid listen deletion request in the absence of an invalid.
- Loading branch information
Showing
5 changed files
with
30 additions
and
5 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
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
15 changes: 15 additions & 0 deletions
15
admin/timescale/updates/2025-02-19-change-listen-delete-metadata-status.sql
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,15 @@ | ||
CREATE TYPE listen_delete_metadata_status_enum AS ENUM ('pending', 'invalid', 'complete'); | ||
|
||
BEGIN; | ||
|
||
ALTER TABLE listen_delete_metadata ADD COLUMN status listen_delete_metadata_status_enum NOT NULL DEFAULT 'pending'; | ||
ALTER TABLE listen_delete_metadata | ||
ADD CONSTRAINT listen_delete_metadata_status_created_constraint | ||
CHECK ( status = 'invalid' OR status = 'pending' OR (status = 'complete' AND listen_created IS NOT NULL) ); | ||
|
||
UPDATE listen_delete_metadata SET status = CASE WHEN deleted IS TRUE 'complete' ELSE 'pending' END; | ||
|
||
ALTER TABLE listen_delete_metadata DROP CONSTRAINT listen_delete_metadata_deleted_created_constraint; | ||
ALTER TABLE listen_delete_metadata DROP COLUMN deleted; | ||
|
||
COMMIT; |
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