]> git.ozlabs.org Git - patchwork/blobdiff - lib/sql/migration/004-msgid-uniqueness.sql
[models] Make patches unique on (msgid, project), not just (msgid)
[patchwork] / lib / sql / migration / 004-msgid-uniqueness.sql
diff --git a/lib/sql/migration/004-msgid-uniqueness.sql b/lib/sql/migration/004-msgid-uniqueness.sql
new file mode 100644 (file)
index 0000000..1e8ac0b
--- /dev/null
@@ -0,0 +1,7 @@
+BEGIN;
+ALTER TABLE patchwork_patch DROP CONSTRAINT "patchwork_patch_msgid_key";
+ALTER TABLE patchwork_comment DROP CONSTRAINT "patchwork_comment_msgid_key";
+
+ALTER TABLE patchwork_patch ADD UNIQUE ("msgid", "project_id");
+ALTER TABLE patchwork_comment ADD UNIQUE ("msgid", "patch_id");
+COMMIT;