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

Make projects identifier non nullable

Christophe Bliard3dc6effdb044
diff --git a/db/migrate/20221130150352_create_project_journals.rb b/db/migrate/20221130150352_create_project_journals.rb
index 216466982b8..c70c7767109 100644
--- a/db/migrate/20221130150352_create_project_journals.rb
+++ b/db/migrate/20221130150352_create_project_journals.rb
@@ -6,7 +6,7 @@ class CreateProjectJournals < ActiveRecord::Migration[7.0]
t.text :description
t.boolean :public, null: false
t.bigint :parent_id
- t.string :identifier
+ t.string :identifier, null: false
t.boolean :active, null: false
t.boolean :templated, null: false
end
diff --git a/db/migrate/20221201140825_add_non_null_constraint_on_projects_identifier.rb b/db/migrate/20221201140825_add_non_null_constraint_on_projects_identifier.rb
new file mode 100644
index 00000000000..b351bb2c0d0
--- /dev/null
+++ b/db/migrate/20221201140825_add_non_null_constraint_on_projects_identifier.rb
@@ -0,0 +1,16 @@
+class AddNonNullConstraintOnProjectsIdentifier < ActiveRecord::Migration[7.0]
+ def change
+ reversible do |dir|
+ dir.up do
+ # should not be needed as all identifiers should be present
+ execute <<~SQL.squish
+ UPDATE projects
+ SET identifier = 'project-' || id
+ WHERE identifier IS NULL
+ SQL
+ end
+ end
+
+ change_column_null :projects, :identifier, false
+ end
+end