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

Add migration to fix hide_mail attribute again

Oliver Güntherfc802323007d
diff --git a/db/migrate/20211118203332_clean_hide_mail.rb b/db/migrate/20211118203332_clean_hide_mail.rb
new file mode 100644
index 00000000000..c826afde74f
--- /dev/null
+++ b/db/migrate/20211118203332_clean_hide_mail.rb
@@ -0,0 +1,19 @@
+class CleanHideMail < ActiveRecord::Migration[6.1]
+ def up
+ execute <<~SQL.squish
+ UPDATE user_preferences
+ SET settings = settings - 'hide_mail' || '{"hide_mail": false}'
+ WHERE settings ->> 'hide_mail' = '0'
+ SQL
+
+ execute <<~SQL.squish
+ UPDATE user_preferences
+ SET settings = settings - 'hide_mail' || '{"hide_mail": true}'
+ WHERE settings ->> 'hide_mail' = '1'
+ SQL
+ end
+
+ def down
+ # Nothing to do
+ end
+end