about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-07-15 14:44:36 -0500
committermultiple creatures <dev@multiple-creature.party>2019-07-15 14:44:36 -0500
commit6f1a07945ee097e5e57f99cbc9b4e5d57e32d79d (patch)
tree099e21ecf229072ac38e2a7b2078d27c2d7a311c /db
parent037be680608d3d60a657761087792c43098c2c2d (diff)
make sure user exists before migrating
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20190531082452_move_account_vars_to_users.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/db/migrate/20190531082452_move_account_vars_to_users.rb b/db/migrate/20190531082452_move_account_vars_to_users.rb
index fea150b78..18664618b 100644
--- a/db/migrate/20190531082452_move_account_vars_to_users.rb
+++ b/db/migrate/20190531082452_move_account_vars_to_users.rb
@@ -1,5 +1,10 @@
 class MoveAccountVarsToUsers < ActiveRecord::Migration[5.2]
   def up
-    Account.local.find_each { |a| a.user.vars = a.vars; a.user.save }
+    Account.local.find_each do |a|
+      if a.user.present?
+        a.user.vars = a.vars
+        a.user.save
+      end
+    end
   end
 end