Sha256: cf6135b1d014176b799b97af00171cda4bda573c60eb574df295947a2f46b942
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
require 'active_record/schema_dumper' module ActiveRecord module Mysql module Comment module SchemaDumper private def table(table, stream) @types = @types.merge(@connection.options_for_column_spec(table)) super(table, stream) ensure @types = @connection.native_database_types end def indexes(table, stream) buf = StringIO.new super(table, buf) buf = buf.string output = add_index_comment(table, buf) stream.print output stream end def add_index_comment(table, buf) output = "" buf.each_line do |line| output << line if matched = line.match(/name: \"(?<name>.*)\", /) index_name = matched[:name] end if index_name.present? comment = @connection.select_one("SHOW INDEX FROM #{table} WHERE Key_name = '#{index_name}';")["Index_comment"] if comment.present? output = output.chop output << ", comment: #{comment.inspect}\n" end end end output end end end end class SchemaDumper #:nodoc: prepend Mysql::Comment::SchemaDumper end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activerecord-mysql-comment-0.0.1 | lib/activerecord-mysql-comment/active_record/schema_dumper.rb |