Skip to content

Commit

Permalink
feat: added clean up sql script
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Jul 3, 2019
1 parent 06584f0 commit 388b441
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions script/prod/clean-up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Deletes all verifications and pact publications that are older than 60 days,
-- and cleans up orphan pacticipant versions and their tags.
-- Also removes webhook execution history.

DELETE FROM verifications WHERE created_at < now() - '60 days'::interval;
DELETE FROM webhook_executions;
DELETE FROM triggered_webhooks;
DELETE FROM pact_publications WHERE created_at < now() - '60 days'::interval;
DELETE FROM pact_versions WHERE id NOT IN (SELECT distinct pact_version_id from pact_publications);
DELETE FROM tags WHERE version_id NOT IN (select consumer_version_id from pact_publications union select provider_version_id from verifications);
DELETE FROM versions WHERE id NOT IN (select consumer_version_id from pact_publications union select provider_version_id from verifications);

0 comments on commit 388b441

Please sign in to comment.