update gang name if already exists
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
class AddInitialGangAndConnectToHomies < ActiveRecord::Migration[5.2]
|
class AddInitialGangAndConnectToHomies < ActiveRecord::Migration[5.2]
|
||||||
def up
|
def up
|
||||||
# execute "INSERT INTO gangs SELECT 'name' WHERE NOT EXISTS (SELECT * FROM gangs)"
|
|
||||||
if Gang.count.zero?
|
if Gang.count.zero?
|
||||||
Gang.create(name: 'Default').save
|
Gang.create(name: 'Default').save
|
||||||
|
elsif Gang.count == 1
|
||||||
|
Gang.update name: 'Default'
|
||||||
end
|
end
|
||||||
gang = Gang.first
|
gang = Gang.first
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user