Module: PgPower::SchemaDumper::CommentMethods
- Included in:
- PgPower::SchemaDumper
- Defined in:
- lib/pg_power/schema_dumper/comment_methods.rb
Overview
Extends ActiveRecord::SchemaDumper class to dump comments on tables and columns.
Instance Method Summary collapse
-
#tables_with_comments(stream) ⇒ Object
Hook ActiveRecord::SchemaDumper#table method to dump comments on table and columns.
Instance Method Details
#tables_with_comments(stream) ⇒ Object
Hook ActiveRecord::SchemaDumper#table method to dump comments on table and columns.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pg_power/schema_dumper/comment_methods.rb', line 5 def tables_with_comments(stream) tables_without_comments(stream) table_names = @connection.tables.sort table_names += get_non_public_schema_table_names.sort # Dump table and column comments table_names.each do |table_name| dump_comments(table_name, stream) end # Now dump index comments unless (index_comments = @connection.index_comments).empty? index_comments.each do |schema_name, table_name, raw_comment| index_name = schema_name == 'public' ? "'#{table_name}'" : "'#{schema_name}.#{table_name}'" comment = format_comment(raw_comment) stream.puts " set_index_comment #{index_name}, '#{comment}'" end stream.puts end end |