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

Rename to bim module in migration

Oliver Günther493da4c8ff09
diff --git a/db/migrate/20200220171133_rename_bim_module.rb b/db/migrate/20200220171133_rename_bim_module.rb
new file mode 100644
index 00000000000..fe3824a6ac2
--- /dev/null
+++ b/db/migrate/20200220171133_rename_bim_module.rb
@@ -0,0 +1,16 @@
+class RenameBimModule < ActiveRecord::Migration[6.0]
+ def up
+ projects_with_bcf = EnabledModule.where(name: 'bcf').pluck(:project_id)
+ EnabledModule.where(name: 'ifc_models').update_all(name: 'bim')
+
+ # Re-enable bim if ifc_models was not active
+ Project.where(id: projects_with_bcf).includes(:enabled_modules).each do |project|
+ project.enabled_module_names << 'bim' unless project.enabled_module_names.include?('bim')
+ end
+ end
+
+ def down
+ # We cannot now which module was active, so enable BCF
+ EnabledModule.where(name: 'bim').update_all(name: 'bcf')
+ end
+end