From 738ad9759ad1c38fb096d3fa567c48bd7a8f49e9 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 30 May 2019 14:30:38 +0300 Subject: Change default to single column UI (#10847) Keep current setting for users who were active within the last month --- ...0529143559_preserve_old_layout_for_existing_users.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb (limited to 'db/migrate') diff --git a/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb b/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb new file mode 100644 index 000000000..72b7c609d --- /dev/null +++ b/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb @@ -0,0 +1,17 @@ +class PreserveOldLayoutForExistingUsers < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def up + # Assume that currently active users are already using the layout that they + # want to use, therefore ensure that it is saved explicitly and not based + # on the to-be-changed default + + User.where(User.arel_table[:current_sign_in_at].gteq(1.month.ago)).find_each do |user| + next if Setting.unscoped.where(thing_type: 'User', thing_id: user.id, var: 'advanced_layout').exists? + user.settings.advanced_layout = true + end + end + + def down + end +end -- cgit