update gang name if already exists

This commit is contained in:
Bilal
2020-10-08 01:28:03 +03:00
parent 8cb44e4b16
commit 9fc4bb6ddb

View File

@@ -1,8 +1,9 @@
class AddInitialGangAndConnectToHomies < ActiveRecord::Migration[5.2]
def up
# execute "INSERT INTO gangs SELECT 'name' WHERE NOT EXISTS (SELECT * FROM gangs)"
if Gang.count.zero?
Gang.create(name: 'Default').save
elsif Gang.count == 1
Gang.update name: 'Default'
end
gang = Gang.first