Remove duplicates from the guix_revisions table
This commit is contained in:
parent
a104fbc5e1
commit
9fc6dd08e6
4 changed files with 52 additions and 0 deletions
37
sqitch/deploy/remove_guix_revision_duplicates.sql
Normal file
37
sqitch/deploy/remove_guix_revision_duplicates.sql
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
-- Deploy guix-data-service:remove_guix_revision_duplicates to pg
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
WITH data AS (
|
||||||
|
SELECT unnest(old_ids) AS old, id FROM (
|
||||||
|
SELECT MIN(id) AS id, ARRAY_AGG(id) AS old_ids
|
||||||
|
FROM guix_revisions
|
||||||
|
GROUP BY commit, git_repository_id
|
||||||
|
HAVING COUNT(id) > 1
|
||||||
|
) AS d2
|
||||||
|
)
|
||||||
|
DELETE FROM guix_revision_package_derivations
|
||||||
|
WHERE revision_id IN (SELECT old FROM data WHERE old != id);
|
||||||
|
|
||||||
|
WITH data AS (
|
||||||
|
SELECT unnest(old_ids) AS old, id FROM (
|
||||||
|
SELECT MIN(id) AS id, ARRAY_AGG(id) AS old_ids
|
||||||
|
FROM guix_revisions
|
||||||
|
GROUP BY commit, git_repository_id
|
||||||
|
HAVING COUNT(id) > 1
|
||||||
|
) AS d2
|
||||||
|
)
|
||||||
|
UPDATE package_versions_by_guix_revision_range
|
||||||
|
SET first_guix_revision_id = data.id
|
||||||
|
FROM data
|
||||||
|
WHERE first_guix_revision_id = data.old;
|
||||||
|
|
||||||
|
DELETE FROM guix_revisions AS g WHERE id NOT IN (
|
||||||
|
SELECT MIN(id)
|
||||||
|
FROM guix_revisions
|
||||||
|
GROUP BY (commit, git_repository_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX ON guix_revisions (commit, git_repository_id);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
7
sqitch/revert/remove_guix_revision_duplicates.sql
Normal file
7
sqitch/revert/remove_guix_revision_duplicates.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- Revert guix-data-service:remove_guix_revision_duplicates from pg
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
-- XXX Add DDLs here.
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
@ -24,3 +24,4 @@ package_versions_by_guix_revision_range 2019-09-26T20:23:15Z Christopher Baines
|
||||||
index_on_load_new_guix_revision_job_events_job_id 2019-09-29T10:39:04Z Christopher Baines <mail@cbaines.net> # Add index on load_new_guix_revision_job_events.job_id
|
index_on_load_new_guix_revision_job_events_job_id 2019-09-29T10:39:04Z Christopher Baines <mail@cbaines.net> # Add index on load_new_guix_revision_job_events.job_id
|
||||||
fix_null_values_in_git_branches 2019-09-29T11:06:12Z Christopher Baines <mail@cbaines.net> # Fix the NULL values in git_branches
|
fix_null_values_in_git_branches 2019-09-29T11:06:12Z Christopher Baines <mail@cbaines.net> # Fix the NULL values in git_branches
|
||||||
add_retry_value_to_job_event_enum 2019-10-02T19:13:52Z Christopher Baines <mail@cbaines.net> # Add retry value to job_event enum
|
add_retry_value_to_job_event_enum 2019-10-02T19:13:52Z Christopher Baines <mail@cbaines.net> # Add retry value to job_event enum
|
||||||
|
remove_guix_revision_duplicates 2019-10-05T08:00:14Z Christopher Baines <mail@cbaines.net> # Remove duplicates in the guix_revisions table
|
||||||
|
|
|
||||||
7
sqitch/verify/remove_guix_revision_duplicates.sql
Normal file
7
sqitch/verify/remove_guix_revision_duplicates.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- Verify guix-data-service:remove_guix_revision_duplicates on pg
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
-- XXX Add verifications here.
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue