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.
25 lines
765 B
Ruby
25 lines
765 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../model"
|
|
|
|
class AssignedVmAddress < Sequel::Model
|
|
one_to_one :vm, key: :id, primary_key: :dst_vm_id
|
|
many_to_one :address, key: :address_id
|
|
one_to_one :active_billing_record, class: :BillingRecord, key: :resource_id, &:active
|
|
|
|
plugin ResourceMethods
|
|
end
|
|
|
|
# Table: assigned_vm_address
|
|
# Columns:
|
|
# id | uuid | PRIMARY KEY
|
|
# ip | cidr | NOT NULL
|
|
# address_id | uuid |
|
|
# dst_vm_id | uuid | NOT NULL
|
|
# Indexes:
|
|
# assigned_vm_address_pkey | PRIMARY KEY btree (id)
|
|
# assigned_vm_address_ip_key | UNIQUE btree (ip)
|
|
# Foreign key constraints:
|
|
# assigned_vm_address_address_id_fkey | (address_id) REFERENCES address(id)
|
|
# assigned_vm_address_dst_vm_id_fkey | (dst_vm_id) REFERENCES vm(id)
|