diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb | 17 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 18 insertions, 1 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 diff --git a/db/schema.rb b/db/schema.rb index cff545be5..f633f4e3f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_05_19_130537) do +ActiveRecord::Schema.define(version: 2019_05_29_143559) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" |