20190529143559_preserve_old_layout_for_existing_users.rb 611 B

12345678910111213141516171819
  1. # frozen_string_literal: true
  2. class PreserveOldLayoutForExistingUsers < ActiveRecord::Migration[5.2]
  3. disable_ddl_transaction!
  4. def up
  5. # Assume that currently active users are already using the layout that they
  6. # want to use, therefore ensure that it is saved explicitly and not based
  7. # on the to-be-changed default
  8. User.where(User.arel_table[:current_sign_in_at].gteq(1.month.ago)).find_each do |user|
  9. next if Setting.unscoped.where(thing_type: 'User', thing_id: user.id, var: 'advanced_layout').exists?
  10. user.settings.advanced_layout = true
  11. end
  12. end
  13. def down; end
  14. end