Class: ActivePostgres::Components::Extensions

Inherits:
Base
  • Object
show all
Defined in:
lib/active_postgres/components/extensions.rb

Constant Summary collapse

EXTENSION_PACKAGES =
{
  'pgvector' => 'postgresql-{version}-pgvector',
  'postgis' => 'postgresql-{version}-postgis-3',
  'pg_trgm' => nil, # Built-in, no package needed
  'hstore' => nil, # Built-in
  'uuid-ossp' => nil, # Built-in
  'ltree' => nil, # Built-in
  'citext' => nil, # Built-in
  'unaccent' => nil, # Built-in
  'pg_stat_statements' => nil, # Built-in
  'timescaledb' => 'timescaledb-2-postgresql-{version}',
  'citus' => 'postgresql-{version}-citus-12.1',
  'pg_partman' => 'postgresql-{version}-partman'
}.freeze

Instance Attribute Summary

Attributes inherited from Base

#config, #secrets, #ssh_executor

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from ActivePostgres::Components::Base

Instance Method Details

#installObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/active_postgres/components/extensions.rb', line 19

def install
  extensions_config = config.component_config(:extensions)
  return unless extensions_config[:enabled]

  extensions = extensions_config[:list] || []
  return if extensions.empty?

  puts 'Installing PostgreSQL extensions...'

  install_on_primary(extensions)
  install_on_standbys(extensions) if config.standbys.any?
end

#install_on_standby(standby_host) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/active_postgres/components/extensions.rb', line 40

def install_on_standby(standby_host)
  extensions_config = config.component_config(:extensions)
  return unless extensions_config[:enabled]

  extensions = extensions_config[:list] || []
  return if extensions.empty?

  puts "Installing extension packages on standby #{standby_host}..."
  install_packages_on_host(standby_host, extensions)
end

#restartObject



36
37
38
# File 'lib/active_postgres/components/extensions.rb', line 36

def restart
  puts 'Extensions do not require restart (loaded at database connection time)'
end

#uninstallObject



32
33
34
# File 'lib/active_postgres/components/extensions.rb', line 32

def uninstall
  puts 'Extensions uninstall not implemented (extensions remain in database)'
end