Module: PgSaurus::SchemaDumper::CommentMethods
- Included in:
- PgSaurus::SchemaDumper
- Defined in:
- lib/pg_saurus/schema_dumper/comment_methods.rb
Overview
Extends ActiveRecord::SchemaDumper class to dump comments on tables and columns.
Instance Method Summary collapse
-
#tables(stream) ⇒ Object
Hook ActiveRecord::SchemaDumper#table method to dump comments on table and columns.
Instance Method Details
#tables(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 |
# File 'lib/pg_saurus/schema_dumper/comment_methods.rb', line 5 def tables(stream) super(stream) # Dump table and column comments @connection.tables.sort.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 |