Skip to content

Commit 0854cbb

Browse files
committed
fix admin_generator rake task to avoid duplicates
1 parent 7f126bd commit 0854cbb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/tasks/admin_generator.rake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# desc "Explaining what the task does"
22
task admin_generator: :environment do
33
app = App.first
4-
app.add_admin(Agent.create(
5-
email: ENV['ADMIN_EMAIL'],
6-
password: ENV['ADMIN_PASSWORD']
7-
))
8-
end
4+
if app.app_users.where(role: "admin", email: ENV['ADMIN_EMAIL']).none?
5+
app.add_admin(Agent.create(
6+
email: ENV['ADMIN_EMAIL'],
7+
password: ENV['ADMIN_PASSWORD']
8+
))
9+
end
10+
end

0 commit comments

Comments
 (0)