salix/db/versions/.archive/10659-azureDracena/00-firstScript.sql

12 lines
341 B
MySQL
Raw Permalink Normal View History

USE vn;
DELETE tc FROM vn.ticketCollection tc
JOIN (
SELECT id, COUNT(ticketFk) counter
FROM vn.ticketCollection
GROUP BY ticketFk
HAVING counter > 1
) sub ON sub.id = tc.id;
ALTER TABLE vn.ticketCollection DROP KEY ticketCollection_UN;
ALTER TABLE vn.ticketCollection ADD CONSTRAINT ticketCollection_UN UNIQUE KEY (ticketFk);