@@ -36,6 +36,10 @@ module AnnotateModels
3636 using : {
3737 default : 'USING' ,
3838 markdown : '_using_'
39+ } ,
40+ comment : {
41+ default : 'COMMENT' ,
42+ markdown : '_comment_'
3943 }
4044 } . freeze
4145
@@ -295,12 +299,22 @@ def index_using_info(index, format = :default)
295299 end
296300 end
297301
302+ def index_comment_info ( index , format = :default )
303+ value = index . try ( :comment ) . try ( :to_s )
304+ if value . blank?
305+ ''
306+ else
307+ " #{ INDEX_CLAUSES [ :comment ] [ format ] } #{ value } "
308+ end
309+ end
310+
298311 def final_index_string_in_markdown ( index )
299312 details = sprintf (
300- "%s%s%s" ,
313+ "%s%s%s%s " ,
301314 index_unique_info ( index , :markdown ) ,
302315 index_where_info ( index , :markdown ) ,
303- index_using_info ( index , :markdown )
316+ index_using_info ( index , :markdown ) ,
317+ index_comment_info ( index , :markdown )
304318 ) . strip
305319 details = " (#{ details } )" unless details . blank?
306320
@@ -314,12 +328,13 @@ def final_index_string_in_markdown(index)
314328
315329 def final_index_string ( index , max_size )
316330 sprintf (
317- "# %-#{ max_size } .#{ max_size } s %s%s%s%s" ,
331+ "# %-#{ max_size } .#{ max_size } s %s%s%s%s%s " ,
318332 index . name ,
319333 "(#{ index_columns_info ( index ) . join ( ',' ) } )" ,
320334 index_unique_info ( index ) ,
321335 index_where_info ( index ) ,
322- index_using_info ( index )
336+ index_using_info ( index ) ,
337+ index_comment_info ( index )
323338 ) . rstrip + "\n "
324339 end
325340
0 commit comments