Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CiviCRM
greenlight
Commits
b0de03cc
Unverified
Commit
b0de03cc
authored
May 27, 2020
by
Ahmad Farhat
Committed by
GitHub
May 27, 2020
Browse files
Fixed migration erroring (#1681)
parent
db6db06a
Changes
1
Hide whitespace changes
Inline
Side-by-side
db/migrate/20200413150518_add_role_id_to_users.rb
View file @
b0de03cc
...
...
@@ -16,7 +16,7 @@ class AddRoleIdToUsers < ActiveRecord::Migration[5.2]
MigrationProduct
.
where
(
role_id:
nil
).
each
do
|
user
|
highest_role
=
SubMigrationProduct
.
joins
(
"INNER JOIN users_roles ON users_roles.role_id = roles.id"
)
.
where
(
"users_roles.user_id = '
#{
user
.
id
}
'"
).
min_by
(
&
:priority
).
id
.
where
(
"users_roles.user_id = '
#{
user
.
id
}
'"
)
&
.
min_by
(
&
:priority
)
&
.
id
user
.
update_attributes
(
role_id:
highest_role
)
unless
highest_role
.
nil?
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment