Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[35999] Add DB constraint on project identifiers (#9265)

Oliver Günther245b0ebbd7d0
diff --git a/db/migrate/20210512121322_make_project_identifier_unique.rb b/db/migrate/20210512121322_make_project_identifier_unique.rb
new file mode 100644
index 00000000000..2ec84f329e5
--- /dev/null
+++ b/db/migrate/20210512121322_make_project_identifier_unique.rb
@@ -0,0 +1,11 @@
+class MakeProjectIdentifierUnique < ActiveRecord::Migration[6.1]
+ def change
+ remove_index :projects, :identifier
+
+ begin
+ add_index :projects, :identifier, unique: true
+ rescue => e
+ raise "You have a duplicate project identifier in your database: #{e.message}"
+ end
+ end
+end