about summary refs log tree commit diff
path: root/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-05-30 14:30:38 +0300
committerGitHub <noreply@github.com>2019-05-30 14:30:38 +0300
commit738ad9759ad1c38fb096d3fa567c48bd7a8f49e9 (patch)
treec7de999fec9a1a2555b76faa1859a504e20a2b8d /db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb
parentdee4f1878ded9848a302f40a8d7523e32531e8c5 (diff)
Change default to single column UI (#10847)
Keep current setting for users who were active within the last month
Diffstat (limited to 'db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb')
-rw-r--r--db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb17
1 files changed, 17 insertions, 0 deletions
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