@@ -667,13 +667,14 @@ class Registration
def save_instance_and_wait(domain, launched)
instance = ::Snikket::CustomerInstance.for(@customer, domain, launched)
repo = ::Snikket::Repo.new(db: @db)
- repo.del(@old).then { repo.put(instance) }.then do
- if launched.status == :needs_dns
- NeedsDNS.new(@customer, instance, @tel, launched.records).write
- else
- GetInvite.for(@customer, instance, @tel, db: @db).then(&:write)
+ (@old&.domain == domain ? EMPromise.resolve(nil) : repo.del(@old))
+ .then { repo.put(instance) }.then do
+ if launched.status == :needs_dns
+ NeedsDNS.new(@customer, instance, @tel, launched.records).write
+ else
+ GetInvite.for(@customer, instance, @tel, db: @db).then(&:write)
+ end
end
- end
end
def empty_nil(s)