Delete rows from pull_requests which map to non-existing issues

This commit is contained in:
Vitaliy Vlasov 2018-04-10 13:59:12 +03:00 committed by Tetiana Churikova
parent eb7b5e1010
commit aaee8a072a
1 changed files with 1 additions and 1 deletions

View File

@ -1,7 +1,7 @@
ALTER TABLE pull_requests DROP CONSTRAINT pull_requests_pkey;
ALTER TABLE pull_requests DROP CONSTRAINT pull_requests_pr_id_key;
DELETE FROM pull_requests p WHERE NOT EXISTS (SELECT issue_id FROM issues i where p.issue_id=i.issue_id);
ALTER TABLE pull_requests ADD CONSTRAINT pull_requests_pkey PRIMARY KEY (pr_id, issue_id);
ALTER TABLE pull_requests ADD CONSTRAINT pull_requests_pr_id_key UNIQUE (pr_id, issue_id);
ALTER TABLE pull_requests ADD CONSTRAINT pull_requests_fkey FOREIGN KEY (issue_id) REFERENCES issues(issue_id);