Allow plugin to take an etc_type keyword argument for using the TYPE_ETC ubid type, and remove the separate definitions in every model that uses the TYPE_ETC ubid type. This was the cleanest way to DRY things up. You cannot extend the models with a module to do this before including ResourceMethods, because then ResourceMethods::ClassMethods will override it, and you cannot extend the models with a module to do this after including ResourceMethods, because the inclusion will not work correctly due to the eager definition of @ubid_format. Best reviewed without whitespace differences.
24 lines
687 B
Ruby
24 lines
687 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../model"
|
|
|
|
class AssignedHostAddress < Sequel::Model
|
|
many_to_one :vm_host, key: :host_id
|
|
many_to_one :address, key: :address_id
|
|
|
|
plugin ResourceMethods
|
|
end
|
|
|
|
# Table: assigned_host_address
|
|
# Columns:
|
|
# id | uuid | PRIMARY KEY
|
|
# ip | cidr | NOT NULL
|
|
# address_id | uuid | NOT NULL
|
|
# host_id | uuid | NOT NULL
|
|
# Indexes:
|
|
# assigned_host_address_pkey | PRIMARY KEY btree (id)
|
|
# assigned_host_address_ip_key | UNIQUE btree (ip)
|
|
# Foreign key constraints:
|
|
# assigned_host_address_address_id_fkey | (address_id) REFERENCES address(id)
|
|
# assigned_host_address_host_id_fkey | (host_id) REFERENCES vm_host(id)
|