We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ce286fd + aee940a commit 14c68ccCopy full SHA for 14c68cc
db/migrate/20190426205807_drop_role_role_users.rb
@@ -7,15 +7,17 @@ def change
7
Entity::Role.reset_column_information
8
9
Entity::Role.find_each do |role|
10
- user_profile_id = ActiveRecord::Base.connection.execute(
+ row = ActiveRecord::Base.connection.execute(
11
<<-SQL.strip_heredoc
12
SELECT "role_role_users"."user_profile_id"
13
FROM "role_role_users"
14
WHERE "role_role_users"."entity_role_id" = #{role.id}
15
SQL
16
).to_a.first
17
18
- role.update_attribute(:user_profile_id, user_profile_id) unless user_profile_id.nil?
+ next if row.nil?
19
+
20
+ role.update_attribute(:user_profile_id, row['user_profile_id'])
21
end
22
23
Entity::Role.where(user_profile_id: nil).delete_all
0 commit comments