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
882 B
Ruby
24 lines
882 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "sequel"
|
|
|
|
class ProjectDiscountCode < Sequel::Model
|
|
many_to_one :project
|
|
many_to_one :discount_code
|
|
|
|
plugin ResourceMethods
|
|
end
|
|
|
|
# Table: project_discount_code
|
|
# Columns:
|
|
# id | uuid | PRIMARY KEY
|
|
# created_at | timestamp with time zone | NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
# project_id | uuid | NOT NULL
|
|
# discount_code_id | uuid | NOT NULL
|
|
# Indexes:
|
|
# project_discount_code_pkey | PRIMARY KEY btree (id)
|
|
# project_discount_code_project_id_discount_code_id_key | UNIQUE btree (project_id, discount_code_id)
|
|
# Foreign key constraints:
|
|
# project_discount_code_discount_code_id_fkey | (discount_code_id) REFERENCES discount_code(id)
|
|
# project_discount_code_project_id_fkey | (project_id) REFERENCES project(id)
|