Files
ubicloud/model/host_provider.rb
Furkan Sahin 9d20fd03b0 Drop HetznerHost table
With the multi stage migration, we are making sure the deployment goes
through with zero downtime. With the 2nd commit, we are switching the
controlplane to start using the new model without destroying the
existing HetznerHost model. Now, with this commit, we can safely delete
the HetznerHost table.
2025-01-31 14:24:34 +01:00

34 lines
862 B
Ruby

# frozen_string_literal: true
require_relative "../model"
class HostProvider < Sequel::Model
many_to_one :vm_host, key: :id
HETZNER_PROVIDER_NAME = "hetzner"
LEASEWEB_PROVIDER_NAME = "leaseweb"
PROVIDER_METHODS = %w[connection_string user password].freeze
PROVIDER_METHODS.each do |method_name|
define_method(method_name) do
Config.send(:"#{provider_name}_#{method_name}")
end
end
def api
@api ||= Object.const_get("Hosting::#{provider_name.capitalize}Apis").new(self)
end
end
# Table: host_provider
# Primary Key: (server_identifier, provider_name)
# Columns:
# id | uuid |
# server_identifier | text |
# provider_name | text |
# Indexes:
# host_provider_pkey | PRIMARY KEY btree (provider_name, server_identifier)
# Foreign key constraints:
# host_provider_id_fkey | (id) REFERENCES vm_host(id)