Files
ubicloud/model/postgres/postgres_metric_destination.rb
Jeremy Evans 14a181620c Add ResourceMethods plugin encrypted_columns argument
This DRYs up setting up encrypted columns for a model. You just
need to specify the column or columns to be encrypted, and the
plugin takes care of setting up the column_encryption plugin.

Other advantages:

* Model.redacted_columns is now an attr_reader, and does not
  need to check for encrypted columns every time it is called.

* Model#before_destroy can look at Model.encrypted_columns (also
  an attr_reader), so it is simplified as well. Simplify the
  method while here by using hash key omission, and make sure
  the constant it uses is frozen.
2025-07-09 05:45:18 +09:00

22 lines
708 B
Ruby

# frozen_string_literal: true
require_relative "../../model"
class PostgresMetricDestination < Sequel::Model
many_to_one :postgres_resource, key: :postgres_resource_id
plugin ResourceMethods, encrypted_columns: :password
end
# Table: postgres_metric_destination
# Columns:
# id | uuid | PRIMARY KEY
# postgres_resource_id | uuid | NOT NULL
# url | text | NOT NULL
# username | text | NOT NULL
# password | text | NOT NULL
# Indexes:
# postgres_metric_destination_pkey | PRIMARY KEY btree (id)
# Foreign key constraints:
# postgres_metric_destination_postgres_resource_id_fkey | (postgres_resource_id) REFERENCES postgres_resource(id)