Module: PgSaurus::SchemaDumper::ExtensionMethods

Included in:
PgSaurus::SchemaDumper
Defined in:
lib/pg_saurus/schema_dumper/extension_methods.rb

Overview

Extends ActiveRecord::SchemaDumper class to dump comments on tables and columns.

Instance Method Summary collapse

Instance Method Details

#extensions(stream) ⇒ Object

Overrides github.com/rails/rails/blob/v7.2.2.2/activerecord/lib/active_record/connection_adapters/postgresql/schema_dumper.rb#L8

Dump current database extensions recreation commands to the given stream.

Parameters:

  • stream (#puts)

    Stream to write to



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pg_saurus/schema_dumper/extension_methods.rb', line 8

def extensions(stream)
  extensions = @connection.pg_extensions
  commands   = extensions.map do |extension_name, options|
    result = [%Q|create_extension "#{extension_name}"|]
    result << %Q|schema_name: "#{options[:schema_name]}"| unless options[:schema_name] == 'public'
    result << %Q|version: "#{options[:version]}"|
    result.join(', ')
  end

  commands.each do |command|
    stream.puts("  #{command}")
  end

  stream.puts

  super
end