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
-
#dump_extensions(stream) ⇒ Object
Dump current database extensions recreation commands to the given stream.
-
#header(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_saurus/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(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_saurus/schema_dumper/extension_methods.rb', line 5 def header(stream) super(stream) dump_extensions(stream) stream end |