Module: PgPower::SchemaDumper::ExtensionMethods
- Included in:
- PgPower::SchemaDumper
- Defined in:
- lib/pg_power/schema_dumper/extension_methods.rb
Overview
Extends ActiveRecord::SchemaDumper class to dump comments on tables and columns.
Instance Method Summary collapse
-
#dump_extensions(stream) ⇒ Object
Dump current database extensions recreation commands to the given stream.
-
#header_with_extensions(stream) ⇒ Object
Hook ActiveRecord::SchemaDumper#header method to dump extensions in all schemas except for pg_catalog.
Instance Method Details
#dump_extensions(stream) ⇒ Object
Dump current database extensions recreation commands to the given stream.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pg_power/schema_dumper/extension_methods.rb', line 14 def dump_extensions(stream) extensions = @connection.pg_extensions commands = extensions.map do |extension_name, | result = [%Q|create_extension "#{extension_name}"|] result << %Q|:schema_name => "#{[:schema_name]}"| unless [:schema_name] == 'public' result << %Q|:version => "#{[:version]}"| result.join(', ') end commands.each do |command| stream.puts(" #{command}") end stream.puts end |
#header_with_extensions(stream) ⇒ Object
Hook ActiveRecord::SchemaDumper#header method to dump extensions in all schemas except for pg_catalog.
5 6 7 8 9 |
# File 'lib/pg_power/schema_dumper/extension_methods.rb', line 5 def header_with_extensions(stream) header_without_extensions(stream) dump_extensions(stream) stream end |