Sha256: 39b0608dfbec282275ce7aeaff7a709a74f51cf1049547dfc45c4854865a28a3

Contents?: true

Size: 588 Bytes

Versions: 9

Compression:

Stored size: 588 Bytes

Contents

include ProxmoxVmUuidHelper
class UpdateProxmoxUuidHost < ActiveRecord::Migration[6.0]
  def up
    execute(sql(:concat))
  end

  def down
    execute(sql(:substring))
  end

  private

  def concat
    "concat(h.compute_resource_id, '_', h.uuid) "
  end

  def substring
    "substring(h.uuid, position('_' in h.uuid) + 1, length(h.uuid)) "
  end

  def sql(func_type)
    sql = 'update hosts h set uuid = '
    sql += send(func_type)
    sql += 'from compute_resources cr '
    sql += "where cr.id = h.compute_resource_id and cr.type = 'ForemanFogProxmox::Proxmox';"
    sql
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
foreman_fog_proxmox-0.16.3 db/migrate/20210312105013_update_proxmox_uuid_host.rb
foreman_fog_proxmox-0.16.2 db/migrate/20210312105013_update_proxmox_uuid_host.rb
foreman_fog_proxmox-0.16.1 db/migrate/20210312105013_update_proxmox_uuid_host.rb
foreman_fog_proxmox-0.16.0 db/migrate/20210312105013_update_proxmox_uuid_host.rb
foreman_fog_proxmox-0.15.1 db/migrate/20210312105013_update_proxmox_uuid_host.rb
foreman_fog_proxmox-0.15.0 db/migrate/20210312105013_update_proxmox_uuid_host.rb
foreman_fog_proxmox-0.14.3 db/migrate/20210312105013_update_proxmox_uuid_host.rb
foreman_fog_proxmox-0.14.2 db/migrate/20210312105013_update_proxmox_uuid_host.rb
foreman_fog_proxmox-0.14.1 db/migrate/20210312105013_update_proxmox_uuid_host.rb