Module: PgSaurus::SchemaDumper::FunctionMethods
- Included in:
- PgSaurus::SchemaDumper
- Defined in:
- lib/pg_saurus/schema_dumper/function_methods.rb
Overview
Support for dumping database functions.
Instance Method Summary collapse
-
#dump_functions(stream) ⇒ Object
Writes out a command to create each detected function.
-
#tables(stream) ⇒ Object
:nodoc.
Instance Method Details
#dump_functions(stream) ⇒ Object
Writes out a command to create each detected function.
16 17 18 19 20 21 22 23 24 |
# File 'lib/pg_saurus/schema_dumper/function_methods.rb', line 16 def dump_functions(stream) @connection.functions.each do |function| statement = " create_function '#{function.name}', '#{function.returning}', <<-FUNCTION_DEFINITION.gsub(/^[\s]{4}/, ''), volatility: :#{function.volatility}" statement << "\n#{function.definition.split("\n").map{|line| " #{line}" }.join("\n")}" statement << "\n FUNCTION_DEFINITION\n\n" stream.puts statement end end |
#tables(stream) ⇒ Object
:nodoc
5 6 7 8 9 10 11 12 13 |
# File 'lib/pg_saurus/schema_dumper/function_methods.rb', line 5 def tables(stream) # Functions must be dumped before tables. # Some indexes may use defined functions. dump_functions stream super(stream) stream end |