diff options
author | Thibaut Girka <thib@sitedethib.com> | 2019-06-03 14:54:30 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2019-06-03 14:54:30 +0200 |
commit | 76918554a6898f9b94d4ffde07face01754fd058 (patch) | |
tree | fa394c02128610793353c0a6ba8363d814147ea4 /db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb | |
parent | 35c4ff07f4d61aaf7ade2ae17060298d62b3f643 (diff) | |
parent | f2f5c1bd6d37ec2ba7d0f98a3c0f8fead6b78f1d (diff) |
Merge remote-tracking branch 'upstream/master' into glitch-soc/merge-upstream
Conflicts: - Gemfile.lock - config/webpack/rules/css.js - package.json - yarn.lock
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.rb | 17 |
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 |