Skip to content
Snippets Groups Projects

remove duplicate staff entries from qa_staff

Merged Charlotte Hausman requested to merge remove_duplicate_staff into main
1 unresolved thread
1 file
+ 27
0
Compare changes
  • Side-by-side
  • Inline
@@ -41,6 +41,33 @@ def upgrade():
WHERE "group" = 'DA';
"""
)
# Remove duplicate entries
op.execute(
"""
CREATE TABLE qa_staff_tmp (LIKE qa_staff);
"""
)
op.execute(
"""
INSERT INTO qa_staff_tmp(user_name, "group", available, email)
SELECT
DISTINCT ON (user_name, "group") user_name, "group", available, email
Please register or sign in to reply
FROM qa_staff;
"""
)
op.execute(
"""
DROP TABLE qa_staff;
"""
)
op.execute(
"""
ALTER TABLE qa_staff_tmp
RENAME TO qa_staff;
"""
)
# Put back unique constraint
op.execute(
"""
ALTER TABLE qa_staff
Loading