github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/atc/db/migration/migrations/1602860419_drop_builds_resource_id_unique.down.sql (about) 1 BEGIN; 2 DROP INDEX builds_resource_id_idx; 3 4 -- prevent conflicts when re-introducing unique constraint by nulling-out all 5 -- but the current check build for each resource 6 UPDATE builds b 7 SET resource_id = NULL 8 WHERE resource_id IS NOT NULL 9 AND NOT EXISTS ( 10 SELECT 1 11 FROM resources 12 WHERE build_id = b.id 13 ); 14 15 CREATE UNIQUE INDEX builds_resource_id_key ON builds (resource_id); 16 17 ALTER TABLE resources DROP COLUMN build_id; 18 COMMIT;