Class: Apartment::Configs::PostgresqlConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/apartment/configs/postgresql_config.rb

Overview

PostgreSQL-specific configuration options.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePostgresqlConfig

Returns a new instance of PostgresqlConfig.



13
14
15
16
# File 'lib/apartment/configs/postgresql_config.rb', line 13

def initialize
  @persistent_schemas = []
  @include_schemas_in_dump = []
end

Instance Attribute Details

#include_schemas_in_dumpObject

Non-public schemas to include in schema dumps (e.g., %w[ext shared]).



11
12
13
# File 'lib/apartment/configs/postgresql_config.rb', line 11

def include_schemas_in_dump
  @include_schemas_in_dump
end

#persistent_schemasObject

Schemas that persist across all tenants (e.g., shared extensions).



8
9
10
# File 'lib/apartment/configs/postgresql_config.rb', line 8

def persistent_schemas
  @persistent_schemas
end

Instance Method Details

#freeze!Object

Freeze mutable collections, then freeze self.



32
33
34
35
36
# File 'lib/apartment/configs/postgresql_config.rb', line 32

def freeze!
  @persistent_schemas.freeze
  @include_schemas_in_dump.freeze
  freeze
end

#validate!Object

Validate persistent_schemas entries as PostgreSQL identifiers. Same rules as tenant names: max 63 chars, valid PG identifier format.



20
21
22
23
24
25
26
27
28
29
# File 'lib/apartment/configs/postgresql_config.rb', line 20

def validate!
  return if @persistent_schemas.blank?

  @persistent_schemas.each do |schema|
    TenantNameValidator.validate_common!(schema)
    TenantNameValidator.validate_postgresql_identifier!(schema)
  rescue ConfigurationError => e
    raise(ConfigurationError, "Invalid persistent_schema #{schema.inspect}: #{e.message}")
  end
end